未登录进入购物车时,从路由从购物车跳转到用户页面时出现报错。
Error: Redirected when going from "/user" to "/cart" via a navigation guard.
因为router版本和vue/lic有冲突,属于官方问题。
解决问题如下:
①在router/index.js中加入这段代码即可(推荐使用)
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)
}
② 删除 node_modules 文件夹,到 package.json 中将 vue-router 改为 3.0.7 ,重新 npm i 即可