All requests before emptying before vue hop routing?

for example, the project is a vue-cli single-page application, so even in the jump routing, the request on the previous page will not stop, which will cause a series of problems.
found a way to cancel the request in the official document of axios, so I tried it in my encapsulated axios, but failed. Ask for advice

figure: I created an instance of axios in base.js and configured canceltoken

clipboard.png

Q: now I want to call the cancel method before each hop route (my beforeEach is in main.js)

Apr.09,2021

execute in the beforeDestoy life cycle of each component


https://github.com/axios/axio.


The

mode is wrong. It shouldn't be like this. You can write a mixin


// 
axios.interceptors.request.use(
    config => {
        // url,
        const url = config.url;
        // cancelaxios.list[url]
        config.cancelToken = new axios.CancelToken(cancel => axios.list[url] = { cancel });
        return config;
    },
    error => Promise.reject(error)
);
//axios.list,listcancel
for(let key in axios.list){
    axios.list[key].cancel();
    //
    delete axios.list[key];
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e45c6a-44b51.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e45c6a-44b51.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?