vue router 清空路由规则方法

替换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

 

上一篇:vue3.0改变路由模式


下一篇:node使用express路由router