vue路由切换时取消之前的所有请求2018-10-26

2018-10-26  本文已影响0人  wangAuraro

在main.js文件里

import router from 'router/';

import Vue from 'vue';

Vue.Cancel = [];

router.beforeEach((to, from, next) => {

    while (Vue.Cancel.length > 0) {

        Vue.Cancel.shift()('cancel');

    }

    next();

})

上一篇 下一篇

猜你喜欢

热点阅读