u
This commit is contained in:
parent
b1ef6d56fa
commit
596f4044d9
@ -51,7 +51,7 @@ export default {
|
||||
: ( i18nText // 如果传入i18n参数 ({zhCN:'...', enUS:'...'})
|
||||
|| this.thisPage()?.i18nText) // 如果不是挂载到 Vue.prototype 而是 挂载到 wo 下调用,那么 this.i18nText 就报错了。因此通过 thisPage().i18nText 访问。
|
||||
const mylang = getApp().$store.state.i18n.mylang // this.thisPage() 有可能为空(例如在 topWindow 里,或者在 App.vue 里),所以用 getApp().$store 更安全
|
||||
return i18nText?.[mylang] || i18nText || ''
|
||||
return i18nText?.[mylang] || (typeof i18nText === 'string' ? i18nText : '') // 必须检测是否string,如果直接返回 i18nText 可能返回{}等,导致依赖于返回空值的前端出错
|
||||
},
|
||||
|
||||
localeText() { // 专供绑定到 computed { lote: wo.localeText } 使用,这时 this 就是当前页面。
|
||||
|
Loading…
Reference in New Issue
Block a user