微信小程序promise解决onload异步

  onLoad: function (options) {
    this.con(4).then(res=>{
      console.log(res)
        
    })
  },
  con(id){
    let thaT=this
    return new Promise((r,t)=>{
      if(id==1){
        r(2)
      }else{
        t(3)
      }
    })
  },

 

posted @ 2020-08-26 15:32  风一样的猿  阅读(1078)  评论(0编辑  收藏  举报