【发布时间】:2021-02-21 17:39:18
【问题描述】:
假设代码是:
<ul>
<li v-for="(lang, i) in $i18n.availableLocales" :key="`Lang${i}`" :value="lang">
<a href="#" @click="setLocale('what shall I write in here?')">
<span> {{ lang.toUpperCase() }} </span>
</a>
</li>
</ul>
所以问题是('what shall I write in here?')
setLocale 函数:
setLocale(locale) {
this.$i18n.locale = locale;
this.$router.push({
params: { lang: locale },
});
},
我尝试使用${$i18n.availableLocales},但它将语言环境更改为IT, FR, EN(总而言之,这是所有可用的语言环境,完全有意义)。
我自己想不通。
谢谢!
【问题讨论】:
-
setLocale(lang)可能吗?