[英]How to add title and script on vue template with nuxtjs
i want to add title
, description
and other html meta
for SEO.我想为 SEO 添加
title
、 description
和其他 html meta
。
how i can do it in vue template?我如何在 vue 模板中做到这一点?
for example i want to add the meta
on my template.vue
.例如我想在我的
template.vue
上添加meta
。
for some reason i have to add script too on that template.出于某种原因,我也必须在该模板上添加脚本。
my code is like this:我的代码是这样的:
head: {
title: 'my title',
script: [
{ src: '/js/theme.js', defer: true }
]
},
code above is error.上面的代码是错误的。
if i use return like this:如果我像这样使用返回:
head () {
return {
title: this.title,
meta: [
{ hid: 'description', name: 'description', content: 'My custom description' }
],
script: [
{ src: '/js/theme.js', defer: true }
]
}
}
meta
will work, but the script will not showing. meta
将工作,但脚本不会显示。
like i say, i can't put the script on nuxt-config.js
don't know why, but the page will error.就像我说的,我不能把脚本放在
nuxt-config.js
,不知道为什么,但是页面会出错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.