uniapp组件中,获取数据延时怎么解决

  最近在做uniapp项目,遇到了数据异步加载,并把数据存储在本地,明明有数据,可是其他页面在onload和onshow的页面获取不到,看了很多方法,有watch监听的,有延时加载的,发现都没有办法从根本上解决问题,我是在onload中做了一个简单的判断
下面展示一些 `内联代码片`。
// A code block


<script>
export default {
  data(){
   return {
    userinfo:'',
    cleartime:''}
}
onLoad(){
   let  that=this
    ifthis.$store.state.uerinfo){            this.userinfo=this.$store.state.userinfo   
     }else{
     if(this.cleartime){
     clearTimeout(this.cleartime)
     this.cleartime= setTimeout(fuction(){     that.userinfo=that.$store.state.userinfo
      },300)
     }
     // 之后再去用异步存储在vuex中公共数据部分    
     
}
}
</script>

你可能感兴趣的:(js,javascript)