如何使用Nuxt在html元素上设置lang属性? [英] How to set lang attribute on html element with Nuxt?
本文介绍了如何使用Nuxt在html元素上设置lang属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用文件 nuxt.config.js
文件,可以自定义 head
内容以添加一些meta或其他内容:
Using the file nuxt.config.js
file, head
contents can be customized to add some meta, or other things:
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
属性.有办法吗?
But I can't find anything in the documentation to set attributes on the html
element -- I want to set the lang
attribute. Is there a way to do that?
推荐答案
来源:声明语言在HTML标签中·问题#388·nuxt/nuxt.js
head
支持 htmlAttrs
属性.它将对象的每个 key:value 映射为 attribute:value
head
supports a htmlAttrs
property. It will map each key:value of the object as attribute:value
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' }
]
},
...
}
这篇关于如何使用Nuxt在html元素上设置lang属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文