补充回去 thisPage = this.$store ? this 的判断,否则找不到组件内的i18nText

This commit is contained in:
陆柯 2021-08-15 16:57:02 +08:00
parent e54f0d78df
commit 70efe57b8b

View File

@ -325,8 +325,8 @@ module.exports = {
},
localeText() {
// 如果直接挂载到 Vue.prototype 下,那么可以直接访问 this.i18nText。但如果通过 this.$T.localeText 访问,那么 this.i18nText 就报错了。因此安全起见,先获取当前 page
let thisPage = getCurrentPages()[getCurrentPages().length - 1]
let thisPage = this.$store ? this // 对于组件内定义的 i18nText要使用 this 而不是 getCurrentPages[...] 去访问。
: getCurrentPages()[getCurrentPages().length - 1] // 如果直接挂载到 Vue.prototype 下,那么可以直接访问 this.i18nText。但如果通过 this.$T.localeText 访问,那么 this.i18nText 就报错了。因此安全起见,先获取当前 page
return thisPage.i18nText[thisPage.$store.state.i18n.mylang]
},