实时搜索竞态问题

172 阅读1分钟
  1. 请求前后状态做关联(shortid)

getList () {
  this.loading = true
  // 记录状态
  let _id = this.id

  api().then(() =>{
    // 若当前状态与记录状态不一样,则直接返回
    if (_id != this.id) return
    ...
  })
}
// abort token 取消请求
//useEffect