猿问

axios 异步请求后.then()后再接.then()要怎么写

doctorComments(this.$route.params.hid, this.$route.params.fid, this.doctorHisId, this.createdon, this.pageno, 5)  //1.axios请求数据

.then(d => {//2.处理数据

  let dc = new Array()

  for(let i=0;i<d.list.length;i++){

    dc[i] = {doctorComments:d.list[i],isZhanshiComment:false}

  }

  this.doctorComments = this.doctorComments.concat(dc);

  this.$refs.scroller.donePullup();

  

})

.then(()=>{//3.调用方法

    this.$options.methods.compareHeightComment();

})

3.里面调用的方法需要doctorcommts这个数组的信息。想要用js promise的相关方法去链式调用,但是我这么写3里面的方法仍然取不到2里面设置的数据。取2里面的数组长度length是undfined。

vue.js.

各位大神,3里面的方法怎么才能取到2设置好后的值。


森林海
浏览 6645回答 2
2回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答