vue中通过axios实现在页面切换时中断请求方法【点击查看详情】
如下所示。,Vue.prototype.$ajax=axios;const CancelToken = axios.CancelToken;let cancel;let cancelAjaxText = '中断成功'Vue.prototype.post = function(url,data,loading){ var ajax = Vue.prototype.$ajax({ method: 'post'.url:url.data: data.cancelToken: new CancelToken(c =>{ //强行中断请求要用到的 cancel = c }) }).then(res =>res.data。
相关视频/文章