问题一、重复点击报错
连续点击同一个路由,第二次点击时报错NavigationDuplicated。如图所示:
vue-router引入的地方加上如下代码段即可
import VueRouter from 'vue-router'
// 解决重复点击菜单导航报错:NavigationDuplicated 的问题
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)
}
详见:
https://blog.youkuaiyun.com/Beam007/article/details/103421755
问题二、短时间内,路由多次跳转会报错
Uncaught (in promise) Error: Navigation cancelled from "/login" to "/home" with a new navigation.
因为默认"/“跳转到”/login","/login"里面有跳转到"/home"