.then 打印不出东西来,不知道什么原因?
发布于 5 年前 作者 yang68 6688 次浏览 来自 问答

//封装promise的一个方法

inspectionOrderList() {

    var that = this

    var p = new Promise(function (resolve, reject) {

    http.inspectionOrderList({ //接口

.....

  })

})

    return p;

},


//在onload里面的调用

this.inspectionOrderList().then(res => {

      console.log("----onload",res)

    })

2 回复
inspectionOrderList() {
  var that = this
 var p = new Promise(function (resolve, reject) {
   http.inspectionOrderList({ 
      success: res=>{
        //获取到了数据res.data;
        console.log(res);
        resolve(res.data); //这个有吗?
      },
    fail: reject
    })
  })
 return p;
}
//在onload里面的调用
this.inspectionOrderList().then(res => {
   console.log("----onload",res)
})

resolve/reject了吗?

回到顶部