u
This commit is contained in:
parent
bb777ea128
commit
d890c19382
@ -47,7 +47,7 @@ export default {
|
|||||||
|
|
||||||
localizeText (i18nText) {
|
localizeText (i18nText) {
|
||||||
i18nText = i18nText?.__page__
|
i18nText = i18nText?.__page__
|
||||||
? this.i18nText // 如果挂载到具体页面的 computed { lote: wo.localizeText } 那么 i18nText 会被自动赋值为 this 就是当前页面,直接取用 this.i18nText 即可。
|
? this.i18nText // 如果挂载到具体页面的 computed { lote: wo.localizeText } 那么 this 就是当前页面,直接取用 this.i18nText 即可。
|
||||||
: i18nText || this.thisPage()?.i18nText // 如果传入i18n参数 ({zhCN:'...', enUS:'...'}) // 如果不是挂载到 Vue.prototype 而是 挂载到 wo 下调用,那么 this.i18nText 就报错了。因此通过 thisPage().i18nText 访问。
|
: i18nText || this.thisPage()?.i18nText // 如果传入i18n参数 ({zhCN:'...', enUS:'...'}) // 如果不是挂载到 Vue.prototype 而是 挂载到 wo 下调用,那么 this.i18nText 就报错了。因此通过 thisPage().i18nText 访问。
|
||||||
const mylang = getApp().$store.state.i18n.mylang // this.thisPage() 有可能为空(例如在 topWindow 里,或者在 App.vue 里),所以用 getApp().$store 更安全
|
const mylang = getApp().$store.state.i18n.mylang // this.thisPage() 有可能为空(例如在 topWindow 里,或者在 App.vue 里),所以用 getApp().$store 更安全
|
||||||
return i18nText?.[mylang] || (typeof i18nText === 'string' ? i18nText : '') // 必须检测是否string,如果直接返回 i18nText 可能返回{}等,导致依赖于返回空值的前端出错
|
return i18nText?.[mylang] || (typeof i18nText === 'string' ? i18nText : '') // 必须检测是否string,如果直接返回 i18nText 可能返回{}等,导致依赖于返回空值的前端出错
|
||||||
@ -453,14 +453,9 @@ export default {
|
|||||||
})
|
})
|
||||||
*/
|
*/
|
||||||
showToast ({ tool, type, image, title, duration = 2000, ...rest }) {
|
showToast ({ tool, type, image, title, duration = 2000, ...rest }) {
|
||||||
const pageNow = this.thisPage()
|
const toast = this.thisPage()?.$refs?.toast || getApp().globalData.toast || wo.toast
|
||||||
const toast = pageNow?.$refs?.toast || getApp().globalData.toast || wo.toast
|
|
||||||
const popupMessage = pageNow?.$refs?.popupMessage || getApp().globalData.popupMessage || wo.popupMessage
|
|
||||||
if (tool!=='uni' && toast) { // 来自 <ucToast> 或 <u-toast> 或 <u-top-tips>
|
if (tool!=='uni' && toast) { // 来自 <ucToast> 或 <u-toast> 或 <u-top-tips>
|
||||||
toast.show({ type, title, duration, ...rest })
|
toast.show({ type, title, duration, ...rest })
|
||||||
} else if (tool!=='uni' && popupMessage) { // 来自 <uni-popup><uni-popup-message></uni-popup-message></uni-popup>
|
|
||||||
popupMessage.popmsg = title
|
|
||||||
popupMessage.open()
|
|
||||||
} else {
|
} else {
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
uni.showToast({ icon: 'none', title, duration, ...rest })
|
uni.showToast({ icon: 'none', title, duration, ...rest })
|
||||||
|
Loading…
Reference in New Issue
Block a user