当我通过导航栏导航到我的动态组件时,vue-meta 标题、内容和架构正确显示,但是当我刷新页面或单击外部链接时,我得到一个未定义的值。
我已将标题内容和架构存储在 json 文件中。
metaInfo() {
return {
title: `${this.seoTitle}`,
meta: [
{name: "robots", content: "index,follow"},
{
name: 'description',
content: `${this.seoContent}`
}
],
link: [
{rel: 'favicon', href: 'logo.ico'}
],
script: [{
type: 'application/ld+json',
json: this.markups
}]
}
},
data() {
return {
seoTitle: this.$route.params.title,
seoContent: this.$route.params.content,
markups:this.$route.params.markup,
}
}
<div class="landing-group-tours box" v-for="tour in boatTours" :key="tour.id">
<router-link
:to="{name: 'details', params:{id: tour.id, title: tour.seoTitle, content: tour.seoContent, markup:tour.markup}}">
</div>
<script>
import tours from '@/data/privateToursData.json'
export default{
data(){
return{
boatTours: tours
{
}
}
</script>