import VueRouter from 'vue-router'
import Vue from 'vue'
Vue.use(VueRouter)
router.options.routes.push(tmp_route) //旧路由
// 2. 创建一个新的 Router 实例(仅用于生成新的 matcher)
// 注意:这里不需要 history 模式,只需要生成 matcher
const newRouter = new VueRouter({
mode: router.mode,
base: router.base,
routes: router.options.routes
})
// 3. 替换当前路由器的 matcher
// 这一步是让路由跳转和匹配立即生效的关键
router.matcher = newRouter.matcher