使用文件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' }
]
},
...
}
但我无法在文档中找到任何设置html
元素属性的内容 - 我想设置lang
属性。有没有办法做到这一点?
答案 0 :(得分:7)
来源:Declaring language in HTML tag · Issue #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' }
]
},
...
}