This commit is contained in:
陆柯 2021-09-21 21:25:18 +08:00
parent 47ead8acbd
commit a5cfcbb992

View File

@ -39,7 +39,7 @@ module.exports = {
localizeText(i18nText) { localizeText(i18nText) {
// 如果直接挂载到 Vue.prototype 下,那么可以直接访问 this.i18nText。但如果通过 this.$T.localeText 访问,那么 this.i18nText 就报错了。因此安全起见,先获取当前 page // 如果直接挂载到 Vue.prototype 下,那么可以直接访问 this.i18nText。但如果通过 this.$T.localeText 访问,那么 this.i18nText 就报错了。因此安全起见,先获取当前 page
const thisPage = this.thisPage() const thisPage = thisPage()
if (i18nText && typeof(i18nText)==='object' && thisPage.$store?.state?.i18n?.mylang) { if (i18nText && typeof(i18nText)==='object' && thisPage.$store?.state?.i18n?.mylang) {
return i18nText[thisPage.$store.state.i18n.mylang] || '' return i18nText[thisPage.$store.state.i18n.mylang] || ''
} }
@ -53,7 +53,7 @@ module.exports = {
}, },
localeText() { localeText() {
const thisPage = this.thisPage() // 如果直接挂载到 Vue.prototype 下,那么可以直接访问 this.i18nText。但如果通过 this.$T.localeText 访问,那么 this.i18nText 就报错了。因此安全起见,先获取当前 page const thisPage = thisPage() // 如果直接挂载到 Vue.prototype 下,那么可以直接访问 this.i18nText。但如果通过 this.$T.localeText 访问,那么 this.i18nText 就报错了。因此安全起见,先获取当前 page
return thisPage.i18nText[thisPage.$store.state.i18n.mylang] return thisPage.i18nText[thisPage.$store.state.i18n.mylang]
}, },
@ -381,7 +381,7 @@ module.exports = {
}) })
*/ */
showToast({ tool, type, image, title, duration = 2000, ...rest }) { showToast({ tool, type, image, title, duration = 2000, ...rest }) {
let pageNow = this.thisPage() const pageNow = thisPage()
if (tool === 'uni' || !(pageNow.$refs && pageNow.$refs.toast)) { if (tool === 'uni' || !(pageNow.$refs && pageNow.$refs.toast)) {
// #ifdef APP-PLUS // #ifdef APP-PLUS
uni.showToast({ icon: 'none', title, duration, ...rest }) uni.showToast({ icon: 'none', title, duration, ...rest })