gpt4 book ai didi

javascript - 如何使用 nuxtjs 在 vue 模板上添加标题和脚本

转载 作者:行者123 更新时间:2023-11-28 03:15:06 24 4
gpt4 key购买 nike

我想添加 titledescription 和其他用于 SEO 的 html meta

如何在 vue 模板中做到这一点?

例如,我想在我的 template.vue 上添加 meta

出于某种原因,我也必须在该模板上添加脚本。

我的代码是这样的:

head: {
title: 'my title',
script: [
{ src: '/js/theme.js', defer: true }
]
},

上面的代码有错误。

如果我像这样使用 return :

head () {
return {
title: this.title,
meta: [
{ hid: 'description', name: 'description', content: 'My custom description' }
],
script: [
{ src: '/js/theme.js', defer: true }
]
}
}

meta 可以工作,但脚本不会显示。

就像我说的,我无法将脚本放在 nuxt-config.js 上,不知道为什么,但页面会出错。

最佳答案

enter image description here检查这张图片希望它能帮助您解决问题

关于javascript - 如何使用 nuxtjs 在 vue 模板上添加标题和脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59713483/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com