替换matcher可以做到 亲测有效 原文链接
import Vue from 'vue' import Router from 'vue-router' Vue.use(Router) const createRouter = () => new Router({ mode: 'history', routes: [] }) const router = createRouter() export function resetRouter () { const newRouter = createRouter() router.matcher = newRouter.matcher // the relevant part } export default router