0
点赞
收藏
分享

微信扫一扫

取消重复的axios请求

Alex富贵 2022-02-14 阅读 56
前端接口

同一个接口,第二次调用时会终止第一次调用,哪怕第一次调用还未结束

var that = this;
if(typeof this.source === 'function'){
    this.source('终止请求')
}
axios({
    method: "",
    url: "",
    cancelToken: new axios.CancelToken(function(c) {
        that.source = c;
    })
}).then((res) => {}).catch(err => {})
举报

相关推荐

0 条评论