解决微信小程序首页空白问题。
This commit is contained in:
@@ -89,7 +89,12 @@
|
||||
},
|
||||
computed: {
|
||||
uniStarterConfig() {
|
||||
return getApp().globalData.config
|
||||
try {
|
||||
const app = getApp({ allowDefault: true });
|
||||
return app && app.globalData ? app.globalData.config : {};
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
},
|
||||
where(){
|
||||
//拼接where条件 查询条件 ,更多详见 :https://uniapp.dcloud.net.cn/uniCloud/unicloud-db?id=jsquery
|
||||
|
||||
@@ -113,8 +113,17 @@
|
||||
cdbRef = this.$refs.udb
|
||||
},
|
||||
async onShow() {
|
||||
this.keyword = getApp().globalData.searchText
|
||||
getApp().globalData.searchText = ''
|
||||
try {
|
||||
const app = getApp({ allowDefault: true });
|
||||
if (app && app.globalData) {
|
||||
this.keyword = app.globalData.searchText;
|
||||
app.globalData.searchText = '';
|
||||
} else {
|
||||
this.keyword = '';
|
||||
}
|
||||
} catch (e) {
|
||||
this.keyword = '';
|
||||
}
|
||||
//这里仅演示如何,在onShow生命周期获取设备位置,并在设备或者应用没有权限时自动引导。设置完毕自动重新获取。
|
||||
//你可以基于他做自己的业务,比如:根据距离由近到远排序列表数据等
|
||||
// uni.showLoading({
|
||||
|
||||
@@ -155,7 +155,12 @@
|
||||
})
|
||||
// #endif
|
||||
|
||||
this.searchText = getApp().globalData.searchText;
|
||||
try {
|
||||
const app = getApp({ allowDefault: true });
|
||||
this.searchText = app && app.globalData ? app.globalData.searchText : '';
|
||||
} catch (e) {
|
||||
this.searchText = '';
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
associativeShow() {
|
||||
@@ -298,7 +303,14 @@
|
||||
this.loadList(item.title);
|
||||
},
|
||||
loadList(text = '') {
|
||||
getApp().globalData.searchText = text;
|
||||
try {
|
||||
const app = getApp({ allowDefault: true });
|
||||
if (app && app.globalData) {
|
||||
app.globalData.searchText = text;
|
||||
}
|
||||
} catch (e) {
|
||||
// 静默失败
|
||||
}
|
||||
uni.switchTab({
|
||||
url:'/pages/list/list'
|
||||
})
|
||||
@@ -318,7 +330,14 @@
|
||||
})
|
||||
} else {
|
||||
this.associativeList.length = 0;
|
||||
getApp().globalData.searchText = '';
|
||||
try {
|
||||
const app = getApp({ allowDefault: true });
|
||||
if (app && app.globalData) {
|
||||
app.globalData.searchText = '';
|
||||
}
|
||||
} catch (e) {
|
||||
// 静默失败
|
||||
}
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
|
||||
@@ -56,7 +56,12 @@
|
||||
},
|
||||
computed: {
|
||||
uniStarterConfig() {
|
||||
return getApp().globalData.config
|
||||
try {
|
||||
const app = getApp({ allowDefault: true });
|
||||
return app && app.globalData ? app.globalData.config : {};
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
},
|
||||
agreements() {
|
||||
if(!uniIdPagesConfig.agreements){
|
||||
|
||||
@@ -23,7 +23,12 @@
|
||||
export default {
|
||||
computed: {
|
||||
uniStarterConfig() {
|
||||
return getApp().globalData.config
|
||||
try {
|
||||
const app = getApp({ allowDefault: true });
|
||||
return app && app.globalData ? app.globalData.config : {};
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
||||
@@ -47,7 +47,12 @@
|
||||
return store.hasLogin
|
||||
},
|
||||
i18nEnable(){
|
||||
return getApp().globalData.config.i18n.enable
|
||||
try {
|
||||
const app = getApp({ allowDefault: true });
|
||||
return app && app.globalData && app.globalData.config && app.globalData.config.i18n ? app.globalData.config.i18n.enable : false;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@@ -215,17 +220,23 @@
|
||||
if(
|
||||
!res.tapIndex && language=='zh-Hans' || res.tapIndex && language=='en'
|
||||
){
|
||||
const globalData = getApp().globalData
|
||||
if (language === 'en') {
|
||||
language = globalData.locale = 'zh-Hans'
|
||||
} else {
|
||||
language = globalData.locale = 'en'
|
||||
}
|
||||
uni.setStorageSync('CURRENT_LANG', language)
|
||||
// 安全地设置 i18n locale,确保 $i18n 存在
|
||||
const app = getApp()
|
||||
if (app && app.globalData && app.globalData.$i18n) {
|
||||
app.globalData.$i18n.locale = language
|
||||
try {
|
||||
const app = getApp({ allowDefault: true });
|
||||
if (app && app.globalData) {
|
||||
const globalData = app.globalData;
|
||||
if (language === 'en') {
|
||||
language = globalData.locale = 'zh-Hans'
|
||||
} else {
|
||||
language = globalData.locale = 'en'
|
||||
}
|
||||
uni.setStorageSync('CURRENT_LANG', language)
|
||||
// 安全地设置 i18n locale,确保 $i18n 存在
|
||||
if (globalData.$i18n) {
|
||||
globalData.$i18n.locale = language
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Settings] 设置语言失败:', e);
|
||||
}
|
||||
this.currentLanguage = res.tapIndex?'简体中文':'English'
|
||||
if(uni.setLocale){
|
||||
|
||||
Reference in New Issue
Block a user