不能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) }