was*_*ful 4 html javascript vue.js nuxt.js vue-meta
使用文件nuxt.config.js文件,head可以自定义内容以添加一些元或其他内容:
module.exports = {
/*
** Headers of the page
*/
head: {
title: 'awesome title',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Nuxt.js project' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
...
}
Run Code Online (Sandbox Code Playgroud)
但我在文档中找不到任何设置html元素属性的东西- 我想设置lang属性.有没有办法做到这一点?
Dan*_*iel 18
在 Nuxt 3 中输入组件
<script setup>
useHead({
htmlAttrs: {
lang: 'en',
style: 'font-size: 13px'
}
})
</script>
Run Code Online (Sandbox Code Playgroud)
https://v3.nuxtjs.org/getting-started/seo-meta/
yur*_*636 14
来源:在HTML标签中声明语言·问题#388·nuxt/nuxt.js
head支持一个htmlAttrs属性.它将映射每个键:对象的值作为属性:值
module.exports = {
head: {
htmlAttrs: {
lang: 'en'
},
title: 'awesome title',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Nuxt.js project' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
...
}
Run Code Online (Sandbox Code Playgroud)
小智 10
添加 htmlAttrs 到nuxt.config.js
export default defineNuxtConfig({
app: {
head: {
htmlAttrs: {
lang: 'en',
},
title: 'title',
charset: 'utf-8',
meta: [],
link: [],
}
},
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2295 次 |
| 最近记录: |