我有一个nuxtjs项目,它在像server\posts\id这样的url上打开页面。在这个页面上,我添加了head信息来影响元标记。但是,有些标记是特定于post的,需要动态填充。这似乎只有在您在mounted中加载数据之后才有可能。如何将元流形添加到mounted中
发布于 2017-04-17 17:01:48
看来你需要一个额外的“数据”属性。如果您在标头中使用这一点,并在稍后更新它,它将更改元信息。
发布于 2020-02-19 11:26:26
从api获取元数据的正确方法是:使用fetch方法
async fetch({ store, params }) {
await store.dispatch('modules/item/get_item', params.article)
},使用计算:
computed: {
...mapState('modules/item', {
Item: (state) => state.data
})
},并使用裸头(vue-meta)
head() {
return {
title:
this.$store.state.modules.general.info.name + ' / ' + this.Item.title,
meta: [
{
hid: 'description',
name: 'description',
content:
this.$store.state.modules.general.info.name +
' / ' +
this.Item.seo_description
},
}https://stackoverflow.com/questions/43455661
复制相似问题