From 008691551573e5faae00e5b2e3026321eaea3d0e Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Mon, 5 Jun 2023 20:25:30 +0800 Subject: [PATCH] allow {xxYY, earth|default} in localizeText() --- unitool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unitool.js b/unitool.js index efd058d..0afd88b 100644 --- a/unitool.js +++ b/unitool.js @@ -45,7 +45,7 @@ export default { i18nText || // 如果传入i18n参数 ({zhCN:'...', enUS:'...'}) this.i18nText || // 1) 如果挂载到具体页面的 computed { lote: wo.localizeText } 那么 this 就是当前页面,直接取用 this.i18nText 即可。2) 对于组件内定义的 i18nText,要使用 this 来获得组件内的 i18nText getCurrentPages()?.pop()?.i18nText // 如果不是挂载到 Vue.prototype 而是 挂载到 wo 下调用,那么 this.i18nText 就不存在了。因此通过 pageNow.i18nText 访问。 - return i18nText?.[my.langNow()] || (typeof i18nText === 'string' ? i18nText : '') // 必须检测是否string,如果直接返回 i18nText 可能返回{}等,导致依赖于返回空值的前端出错 + return i18nText?.[my.langNow()] || i18nText?.earth || i18nText?.default || (typeof i18nText === 'string' ? i18nText : '') // 必须检测是否string,如果直接返回 i18nText 可能返回{}等,导致依赖于返回空值的前端出错 }, localeText () {