美文网首页
vue中axios请求终止上一次请求

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

作者: sunowter | 来源:发表于2021-06-28 10:23 被阅读0次

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

      }) 

  });

相关文章

网友评论

      本文标题:vue中axios请求终止上一次请求

      本文链接:https://www.haomeiwen.com/subject/ymcqultx.html