Answer the question
In order to leave comments, you need to log in
Why does it give an error on the server when refreshing the page?
My dynamic page
<template>
<div>
<component
:is="componentName"
:data="data"
/>
</div>
</template>
<script>
import Card from '@/components/main/pages/Card'
import Post from '@/components/main/pages/Post'
import Tag from '@/components/main/pages/Tag'
export default {
components: {
Card,
Post,
Tag
},
data() {
return {
data: '',
componentName: ''
}
},
async beforeRouteEnter(to, from, next) {
const store = from.matched[0].instances.default.$store
const res = await store.dispatch('data/getData', to.params.slug)
console.log(res);
next(vm => {
vm.data = res.card
vm.componentName = res.category;
})
}
}
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question