Zr *_*sic 2 javascript routes internationalization vue.js nuxt.js
还有人问这个问题吗?如果是,请给我阅读这个问题的链接,如果不是,该怎么做?我想更改每个用户切换语言的标题和描述,我该怎么做?我确实喜欢得到一些帮助,我是。初学者:D
我有gallery.vue
我在这里使用 nuxt js
并使用基于 nuxt-i18n 的 vue-i18n
<template lang="html">
<div class="">
<p> {{ $t('post') }}</p>
</div>
</template>
<script>
export default {
head () {
return {
tittle: // how to change tittle here for the spesific languange
}
}
}
</script>
<style lang="css">
</style>
Run Code Online (Sandbox Code Playgroud)
我希望结果就像英语中的标题是 Gallery 一样,当用户切换意大利语时,标题将是 Galleria
小智 5
这可能有点晚了,但可以帮助新人。
根据文档,您可以使用函数来设置元数据,以便使用函数访问数据并计算(包括这个),检查代码:
head() {
return {
title: this.$t('myTitle'),
htmlAttrs: {
lang: this.$i18n.locale,
},
meta: [
{
hid: 'description',
name: 'description',
content: this.$t('myDescription'),
},
],
}
Run Code Online (Sandbox Code Playgroud)
},
来源:https://nuxtjs.org/docs/2.x/features/meta-tags-seo#local-settings