如何在 vue-resource http 拦截器中重定向用户?

How to redirect user inside vue-resource http interceptor?

我想在出现 401 时重定向用户,但我无法从此上下文访问 router

  Vue.http.interceptors.push(function(request, next) {
    // continue to next interceptor
    next(function(response) {
        if(response.status == 401){
            //redirect user here
            //tried: Vue.$router and Vue.$route 
        }

    });
  });

我该怎么做?

使用:Vue-router 和 Vue-resource

const router = new VueRouter({
  routes
})

Vue.http.interceptors.push(function(request, next) {
    // continue to next interceptor
    next(function(response) {
        if(response.status == 401){
            router.push(...) 
        }
    });
 });