Vue Router - 记录一下 2 种路由写法

记录一下 2 种路由写法

  1. 如下写法,可以通过 /test/myTest/test 访问到 MyTest,更推荐此写法
js 复制代码
{
    name: "Test",
    path: "/test",
    component: "Layout",
    redirect: "/test/myTest",
    meta: {
        noCache: true,
        title: "测试",
        icon: "tool",
        link: null,
    },
    children: [
        {
            path: "myTest",
            component: "test/myTest/index",
            name: "MyTest",
            meta: {
                noCache: true,
                title: "我的测试",
                icon: "tool",
            },
        },
    ],
},
  1. 如下写法,可以通过 /test/myTest 访问到 MyTest,不能通过 /test 访问到 MyTest(404)
js 复制代码
{
    name: "Test",
    path: "",
    component: "Layout",
    redirect: "/test/myTest",
    meta: {
        noCache: true,
        title: "测试",
        icon: "tool",
        link: null,
    },
    children: [
        {
            path: "/test/myTest",
            component: "test/myTest/index",
            name: "MyTest",
            meta: {
                noCache: true,
                title: "我的测试",
                icon: "tool",
            },
        },
    ],
},
相关推荐
To_OC1 小时前
LC 200 岛屿数量:经典 DFS 入门题,我第一次写居然连方向都搞错了
javascript·算法·leetcode
Asmewill1 小时前
grep&curl命令学习笔记
前端
stringwu1 小时前
Flutter 开发必备:MVI 架构的高效实现指南
前端·flutter
用户2136610035722 小时前
Vue2组件化开发与父子通信
前端·vue.js
Momo__3 小时前
TypeScript satisfies 操作符——比 as 更安全的类型守门员
前端·typescript
用户2136610035723 小时前
Vue2事件系统与指令进阶
前端·vue.js
labixiong3 小时前
实现一个能跑的迷你版Promise(一)
前端·javascript·面试
Csvn5 小时前
`??` 和 `||` 搞混,线上用户头像全挂了
前端
kyriewen5 小时前
白宫前脚下了限制令,OpenAI 后脚就把 GPT-5.6 发了
前端·gpt·openai
用户40269244819086 小时前
CRMEB Pro 新增后台接口全链路:路由、权限、验证器、返回格式一次讲清
前端·后端