SOURCE

//axios 取消请求
//第一种方式,工厂模式
const cancelToken = axios.cancelToken;
const source = cancelToken.source;
axios.get("/get/user", {
    cancelToken: source.token
})
setTimeout(() => {
    source.cancel()
}, 3000)

//第二种方式,构造函数模式
let cancel;
axios.get("/get/user", {
    cancelToken: new axios.cancelToken(function executor(c) {
        cancel = c;
    })
})
setTimeout(() => {
    cancel()
}, 3000)
console 命令行工具 X clear

                    
>
console