解决:在vue-router的index.js中添加如下代码
//先保存router原型对象的push let originPush = VueRouter.prototype.push let originReplace = VueRouter.prototype.replace //第一个参数:告诉push方法往哪里跳转,并传递哪些参数 //第二个参数: 成功回调 //第三个参数:失败回调 VueRouter.prototype.push = function(location, resolve, reject) { if (resolve && reject) { //js中的每个函数都有call和apply方法,唯一区别就是call传参用逗号隔开,apply使用数组,相同点都可以调用函数一次 originPush.call(this, location, resolve, reject) } else { originPush.call(this, location, () => {}, () => {}) } } VueRouter.prototype.replace = function(location, resolve, reject) { if (resolve && reject) { //js中的每个函数都有call和apply方法,唯一区别就是call传参用逗号隔开,apply使用数组,相同点都可以调用函数一次 originReplace.call(this, location, resolve, reject) } else { originReplace.call(this, location, () => {}, () => {}) } }
标签:resolve,跳转,NavigationDuplicated,call,location,VueRouter,reject,apply,路由 From: https://www.cnblogs.com/ixtao/p/17231567.html