報錯:Uncaught (in promise) Error: Redirected when going from "/login" to "/homePage" via a navigation guard.
解決方法一:
在路由文件添加:
// 解決Vue-Router升級導致的Uncaught(in promise) navigation guard問題
const originalPush = VueRouter.prototype.push;
VueRouter.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);
};
解決方法二:
在跳轉路由添加箭頭函數(shù)
this.$router.push('/home',()=>{})