我正在尝试为特定组件扩展已经加载的本地化,我想做这样的事情:
export default {
name: 'General',
components: {
Header,
Content,
NextPageButton
},
i18n: {
messages: {
[this.$i18n.locale]: { message: require('@/locales/' + this.$i18n.locale + '/tso/general.json') }
}
}
问题当然是 $i18n 在 i18n 选项中未定义。如何在此处检索当前语言环境?
最佳答案
我像这样使用 Vue 实例:this.Vue.$i18n.locale
另一种访问方式是this.$root.$i18n.locale
关于javascript - Vue i18n - 如何在 i18n 组件选项中获取当前语言环境?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60492720/