本文主要是介绍vue或F12报错:Redirected when going from “/login?redirect=%2Findex“ to “/index“ via a navigation guard.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
分析问题:vue router升级导致没有向下兼容
解决方法:路由router中添加如下代码
import Vue from 'vue'
import Router from 'vue-router'
# 找到你的vue-router,添加下面的代码 把Router改成你命名的名称就行,别的不用动const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)return originalPush.call(this, location).catch((err) => err)
}
这篇关于vue或F12报错:Redirected when going from “/login?redirect=%2Findex“ to “/index“ via a navigation guard.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!