uni.setStorageSync在登录页面设置缓存,第一次进入首页在onload里面获取不到缓存数据的解决办法
在onLoad里面获取不到缓存:
onLoad(option) { const token = uni.getStorageSync('token'); if(!token){ uni.showToast({ title:"请先登录", icon:"error", mask:true }); setTimeout(()=>{ //跳转到登录 uni.navigateTo({ url: '/pages/login/login' }); },1500); }; },
在created里面就可以获取的到
created() { const checkInformation = uni.getStorageSync('checkInformation'); this.userName = checkInformation.personName; this.balance = checkInformation.balance; this.userAddress = checkInformation.projectName+'-'+checkInformation.roomName; },

浙公网安备 33010602011771号