axios.CancelToken
取消发送中的请求
const CancelToken = axios.CancelToken
window.cancle = null
export const getImagePhoto = params => {
return jsonRequest({
url: '',
method: 'get',
params,
cancelToken: new CancelToken(function executor (cancel) {
// executor 函数接收一个 cancel 函数作为参数
window.cancle = cancel
})
}).then(res => res.data)
}
getBusinessCardAvatar () {
window.cancle && window.cancle()
getImagePhoto({
userId: this.saleNo
}).then(res => {
if (res.success) {
resolve(res)
} else {
console.error(res.errorMessage)
resolve(res)
}
})
}