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",
            },
        },
    ],
},
相关推荐
山东点狮信息科技有限公司34 分钟前
企业级开源OA系统推荐
vue.js·spring boot·性能优化·系统架构·开源
易知微EasyV数据可视化34 分钟前
定制化3D组件开发:打造差异化孪生体验
前端·人工智能·经验分享·数字孪生
多加点辣也没关系42 分钟前
JavaScript|第24章:事件循环与并发模型
开发语言·javascript·ecmascript
前端炒粉1 小时前
Vue2 SSE 流式对话完整前端代码
前端·sse·流式输出
BIM云平台开发2 小时前
【App.vue里跟踪页面跳转和用户ID】
开发语言·前端·javascript
汪汪大队u2 小时前
Zabbix 6.0 部署踩坑记:从启动失败到 Web 成功访问
前端·zabbix
顺颂时绥_12 小时前
new Set 过滤数据实战
前端
赵大仁2 小时前
Next.js + Vercel AI SDK 实战:30 分钟搭出流式 Chat 页面
前端·ai·实战·react·next.js·vercel
云空3 小时前
《Three.js 完整版3D魔方:带贴纸+中心固定+自动求解复原》
前端·javascript·3d·three.js
酸梅果茶3 小时前
【7】lightning_lm项目-LIO 前端 -IVox 局部地图
前端·slam