Axios async request. Then () and then. How to write 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;iPP){
    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. The method called in requires information about the doctorcommts array. I want to use the relevant methods of js promise to chain calls, but I still can"t get the data set in 2 when I write the method in 3. The array length length in 2 is undfined.
vue.js.
Gods, how can the method in 3 get the value set by 2?

Mar.02,2021

return to give you an example, the arrow function is followed by return

.
Promise.resolve(1).then(v=> {
    console.log(v)//1
    return 123;
}).then(v => {
    console.log(v)//123
})
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;iPP){
    dc[i] = {doctorComments:d.list[i],isZhanshiComment:false}
  }
  this.doctorComments = this.doctorComments.concat(dc);
  this.$refs.scroller.donePullup();
  return this.doctorComments;
})
.then((v)=>{//3. 
    console.log(v);vthis.doctorComments
})

the cause was later found out. This points to a method that is not the current vue instance in the method called after then. If you use this, in the called method, you will never find the value. According to the usage of Li Shisheng, pass the current vue instance before promise.

let that = this;//promise 
...//
.then() //
.then(func(that){...}); //


//
func(that){
that.xxx   //vue
that.xxx
}
This that instance is used in the method called by

. In the end,
is strictly a matter of scope.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be4206-39a8e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be4206-39a8e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?