vue router路由反复触发导致的报错
VueUncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/ 或者vue Uncaught Error: Redirected when going from “/*“ to “/*“
废话不多说
办法1:
https://mp.csdn.net/editor/ht...
这种解决办法能够是能够,然而办法2感觉更好些
this.$router.replace({ path: this.$route.path, query }) .catch(()=>{});//把error 抛出来
办法2:
倡议认真看看github上这个探讨计划 说的很具体 https://github.com/vuejs/vue-...
//初始化 注入路由中央import Vue from 'vue'import Router from 'vue-router'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);};Vue.use(Router)...const router = new Router({ routes})...