From 70efe57b8baaf825989a021d1eed0a6f4487b403 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sun, 15 Aug 2021 16:57:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=9B=9E=E5=8E=BB=20thisPage?= =?UTF-8?q?=20=3D=20this.$store=20=3F=20this=20=E7=9A=84=E5=88=A4=E6=96=AD?= =?UTF-8?q?=EF=BC=8C=E5=90=A6=E5=88=99=E6=89=BE=E4=B8=8D=E5=88=B0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=86=85=E7=9A=84i18nText?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0496ddc..52d0935 100644 --- a/index.js +++ b/index.js @@ -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] },