不能push相同的地址,否则会出 Uncaught (in promise) NavigationDuplicated vue-router.esm.js?fe87:2089 的报错。
解决办法:
import VueRouter from 'vue-router' const originalPush = VueRouter.prototype.push VueRouter.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) }