在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; },
标签:onload,缓存,setStorageSync,登录,获取,token,页面设置,checkInformation,uni From: https://www.cnblogs.com/jianglinqian/p/17972240