vue中axios请求终止上一次请求

2021-06-28  本文已影响0人  sunowter

data(){

return{

cancel:''

}

methods:{

     cancelRequest(){

        if(typeof this.cancel ==='function'){

            this.cancel('终止请求')

        }

      },

}

getOrderList(){

this.cancelRequest

await getOrderList(params,this)
}

api中:

export function getOrderList(data,self) {

  return request({

    url: `${teacherPath}/sys/order/v1/getOperatorOrderV2`,

    method: "get",

    params: data,

    cancelToken: new axios.CancelToken (function executor(c) {

        self.cancel = c

      }) 

  });

上一篇 下一篇

猜你喜欢

热点阅读