当前位置: 首页 > Web前端 > vue.js

VueUncaught(inpromise)NavigationDuplicated...

时间:2023-03-31 15:50:32 vue.js

vueroutertriggers重复触发错误VueUncaught(inpromise)NavigationDuplicated:Avoidedredundantnavigationtocurrentlocation:"/orvueUncaughtError:Redirectedwhengoingfrom"/*"to"/*"废话不多说方法一:https://mp.csdn.net/editor/ht...这个方案可以做,但是方法二感觉更好this.$router.replace({path:this.$route.path,query}).catch(()=>{});//抛出错误方法二:建议仔细看看github上的讨论方案,很详细https://github.com/vuejs/vue-...//初始化注入路由importVuefrom'vue'importRouterfrom'vue-router'constoriginalPush=Router.prototype.push;Router.prototype.push=functionpush(location,onResolve,onReject){if(onResolve||onReject)returnoriginalPush.call(this,location,onResolve,onReject);returnoriginalPush.call(this,location).catch(err=>err);};Vue.use(路由器)...const路由器=新路由器({路由})...