Javascript 如何使用nuxtjs在vue模板上添加标题和脚本
我想为搜索引擎优化添加Javascript 如何使用nuxtjs在vue模板上添加标题和脚本,javascript,vue.js,nuxt.js,Javascript,Vue.js,Nuxt.js,我想为搜索引擎优化添加标题,说明和其他html元数据 如何在vue模板中执行此操作 例如,我想在我的template.vue上添加meta 出于某种原因,我不得不在该模板上添加脚本 我的代码如下: head: { title: 'my title', script: [ { src: '/js/theme.js', defer: true } ] }, head () { return { title: this.title, meta:
标题
,说明
和其他html元数据
如何在vue模板中执行此操作
例如,我想在我的template.vue
上添加meta
出于某种原因,我不得不在该模板上添加脚本
我的代码如下:
head: {
title: 'my title',
script: [
{ src: '/js/theme.js', defer: true }
]
},
head () {
return {
title: this.title,
meta: [
{ hid: 'description', name: 'description', content: 'My custom description' }
],
script: [
{ src: '/js/theme.js', defer: true }
]
}
}
上面的代码是错误的
如果我像这样使用return:
head: {
title: 'my title',
script: [
{ src: '/js/theme.js', defer: true }
]
},
head () {
return {
title: this.title,
meta: [
{ hid: 'description', name: 'description', content: 'My custom description' }
],
script: [
{ src: '/js/theme.js', defer: true }
]
}
}
meta
将起作用,但脚本不会显示
就像我说的,我不能将脚本放在numxt config.js上,我不知道为什么,但是页面会出错。检查此图像希望它能帮助您解决问题检查此图像希望它能帮助您解决问题