问题
Vue路由当你重复传相同参数时,控制台就会报:NavigationDuplicated
原因:
最新的vue-router引入了promise
解决方法
通过给push方法传递相应的成功,失败的回调,可以捕获当前错误,可以解决问题
12345678910111213this.$router.push({name: 'search',query: {k: this.keyword.toUpperCase(),},params: {keyword: this.keyword,},},() => { }, //函数传入成功() => { } //函数传入失败);
但是这种方法治标不治本!!!
重写Router原型对象上的push方法和replace方法
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849// ...