Head 方法
Nuxt 使用 vue-meta 来更新应用程序的 headers 和 html attributes。
-
类型:
Object或Function
使用 head 方法为当前页面设置 HTML head 标签。
<template>
<h1>{{ title }}</h1>
</template>
<script>
export default {
data() {
return {
title: 'Hello World!'
}
},
head() {
return {
title: this.title,
meta: [
// hid 用作唯一标识符,请勿使用 `vmid`,它不起作用。
{
hid: 'description',
name: 'description',
content: 'My custom description'
}
]
}
}
}
</script>
为避免在子组件中使用时出现重复的 meta 标签,请使用 meta 元素的
hid 键设置唯一标识符(详情请参阅此处 )。
Edit this page on GitHub
Updated at Tue, Apr 14, 2026