-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed as not planned
Description
Version
4.0.6
Reproduction link
Steps to reproduce
import { createRouter, createWebHistory, createWebHashHistory, RouteRecordRaw } from "vue-router";
import NotFound from "../views/NotFound.vue";
import Login from "../views/login/login.vue";
import Test from "../views/test/test.vue";
// 静态路由
const routes: Array = [
{ path: '/', redirect: '/index', meta: { menuShow: false, } },
{ path: "/login", name: "Login", component: Login, meta: { menuShow: false, } },
{ path: "/404", name: "NotFound", component: NotFound, meta: { menuShow: false, } },
];
const router = createRouter({
history: createWebHashHistory(),
routes: routes,
})
router.beforeEach(async (to, from, next) => {
router.addRoute({ path: "/test", name: "Test", component: Test })
next()
})
export default router;
What is expected?
router能够正常访问
What is actually happening?
动态路由router.addRoute无效,无法动态添加router,无法访问
Metadata
Metadata
Assignees
Labels
No labels