【发布时间】:2021-08-31 11:19:01
【问题描述】:
我有一个产品页面,我在其中传递产品 ID 并基于此我调用 rest Api 并且在 Api 响应之后我需要使用产品名称更新标题标签。我能够更新标题标签,但在查看源代码中我将值作为未定义或默认值。那么如何在开始时更新标题,以便在查看源中获取产品名称。所以这将是 SEO 友好的。
export default {
name: 'App',
components: {
HelloWorld
},
data () {
return {
setTitle: {}
}
},
created () {
axios.get('https://apiurl.com/testing.json')
.then((response) => {
this.setTitle = response.data
})
},
metaInfo() {
return {
title: `${this.setTitle.product_name} product name`,
meta: [
{
vmid: "description",
name: "description",
content:
"hello world, this is an example of adding a description with vueMeta"
}
]
}
}
}
如果在我的项目中 SSR 为假,是否有可能?
【问题讨论】:
标签: javascript vue.js axios nuxt.js