【发布时间】:2019-08-17 01:49:44
【问题描述】:
我想将我的应用英语翻译成德语。 关于语言更改事件,我写了这段代码
changeLocale (locale) {
i18n.locale = locale.language
VueCookies.set('UserLanguage', locale.language)
// window.location.reload() this one is reloading page
this.$root.reload() // this one is not working
},
我想在 vuejs 文件中翻译这些数据:
DashboardData: [{'name': this.$t('IVR')}, {'name': this.$t('DTML')}, {'name': this.$t('SSH')}]
如果我执行 window.location.reload(),它会完美运行 但我不想重新加载页面所以,我正在考虑在 vue 中重新加载 root,我不确定。
有没有办法重新加载整个应用程序的根元素或所有属性?
【问题讨论】:
-
如果您尝试在
data块中使用它,我认为this.$t是未定义的。您可以尝试改用this.$i18n.t,或者将您的DashboardData移动到计算属性并继续使用this.$t。
标签: vue.js vuejs2 vue-component vuex vue-router