Skip to content

No match found for location with path "/index" #896

@AIKE-Dereks

Description

@AIKE-Dereks

Version

4.0.6

Reproduction link

https://new-issue.vuejs.org/

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions