vue 菜单路由重复点击报错NavigationDuplicated
NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated", message: "Navigating to current location ("/produce/delivery-order") is not allowed", stack: "Error↵at new Navi...
·
NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated", message: "Navigating to current location ("/produce/delivery-order") is not allowed", stack: "Error↵ at new NavigationDuplicated (webpack-int…_modules/_vue@2.6.10@vue/dist/vue.esm.js:1862:26)"}
解决方法:
在router.js中加入以下代码就可以
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
方法二
created() {
const defaultHref = this.menuList[0].children ? this.defaultActive(this.menuList[0].children) : this.menuList[0]
if (this.$route.path !== defaultHref.href) {
this.$router.replace({
path: defaultHref.href
})
}
},
更多推荐
已为社区贡献39条内容
所有评论(0)