u
This commit is contained in:
parent
d2522000eb
commit
173e28618d
9
index.js
9
index.js
@ -28,17 +28,12 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
localizeText(i18nText) {
|
localizeText(i18nText) {
|
||||||
// 如果直接挂载到 Vue.prototype 下,那么可以直接访问 this.i18nText。但如果通过 this.$T.localeText 访问,那么 this.i18nText 就报错了。因此安全起见,先获取当前 page
|
|
||||||
const pageNow = this?.$store ? this // 对于组件内定义的 i18nText,要使用 this 来获得组建内的 i18nText,而不是 getCurrentPages[...] 去访问全局页面的 i18nText。
|
const pageNow = this?.$store ? this // 对于组件内定义的 i18nText,要使用 this 来获得组建内的 i18nText,而不是 getCurrentPages[...] 去访问全局页面的 i18nText。
|
||||||
: getCurrentPages()[getCurrentPages().length - 1]
|
: getCurrentPages()[getCurrentPages().length - 1] // 如果直接挂载到 Vue.prototype 下,那么可以直接访问 this.i18nText。但如果通过 this.$T.localeText 访问,那么 this.i18nText 就报错了。因此安全起见,先获取当前 page
|
||||||
// 支持 localizeText({...}) 来解析参数
|
i18nText = i18nText || pageNow.i18nText // 解析输入参数 i18nText,或者 pageNow.i18nText
|
||||||
if (i18nText && typeof(i18nText)==='object' && pageNow.$store?.state?.i18n?.mylang) {
|
if (i18nText && typeof(i18nText)==='object' && pageNow.$store?.state?.i18n?.mylang) {
|
||||||
return i18nText[pageNow.$store.state.i18n.mylang] || ''
|
return i18nText[pageNow.$store.state.i18n.mylang] || ''
|
||||||
}
|
}
|
||||||
// 支持 localizeText() 来解析 页面.vue 的顶层 i18nText
|
|
||||||
if (!i18nText && typeof(pageNow.i18nText)==='object' && pageNow.$store?.state?.i18n?.mylang) {
|
|
||||||
return pageNow.i18nText[pageNow.$store.state.i18n.mylang] || ''
|
|
||||||
}
|
|
||||||
if (typeof i18nText === 'string'){
|
if (typeof i18nText === 'string'){
|
||||||
return i18nText
|
return i18nText
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user