回复小生:main.js 中
Vue.prototype.$onlaunched = new Promise (resolve=>{
Vue.prototype.$isResolve = resolve
})
app.vue中
// 微信
wx.login({
success:(res)=> { // 获取code if(res.code){ if(false){ uni.setStorageSync('isbinding',false) }else{ uni.setStorageSync('isbinding',true) } this.$isResolve(); console.log(res) }else{ console.log('登录失败!',res.errMsg) }
}
})
index.vue 中
data()
async onload(){
await that.$onlaunched
that.isbinding = uni.getStorageSync('isbinding')
}
这样写会有一个不到一秒的抖动 that.isbinding的值会先为false 再变为true
而根据这个变量判断页面是否显示 刚开始半秒的时间不显示,然后才显示