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",
            },
        },
    ],
},
相关推荐
xkxnq2 分钟前
第八阶段:工程化、质量管控与高级拓展(130天),Vue端到端测试:Cypress自动化测试(登录流程+表单提交+页面跳转)
前端·vue.js·flutter
小雨下雨的雨4 分钟前
基于鸿蒙PC Electron框架技术完成的五子棋游戏 - 技术实现详解
前端·javascript·游戏·华为·electron·鸿蒙
cheems95276 分钟前
[开发日记]Spring Boot + MyBatis-Plus 抽奖系统开发复盘:从奖品创建、活动校验到前端圈选人员失效的一次完整排障
前端·spring boot·mybatis
老毛肚6 分钟前
jeecgboot vue API 拆分02
前端·javascript·vue.js
赵谨言13 分钟前
基于C#的在线编码与自动化测试全栈Web平台的设计与实现
开发语言·前端·c#
Raink老师17 分钟前
【AI面试临阵磨枪-98】前端如何展示多模态流式输出:文字打字机 + 图片渐进 + 音频播放?
前端·人工智能·面试
AI_零食20 分钟前
奶茶大数据运维表 - 鸿蒙PC Electron框架技术实现详解
运维·前端·华为·electron·开源·harmonyos·鸿蒙
小雨下雨的雨22 分钟前
鸿蒙PC Electron框架实现流体气泡模拟器
前端·人工智能·算法·华为·electron·鸿蒙
ZC跨境爬虫23 分钟前
跟着 MDN 学JavaScript day_4:如何存储你需要的信息——变量
开发语言·前端·javascript·ui·ecmascript
星栈独行25 分钟前
10 分钟跑起第一个 Makepad 应用:先把窗口开起来
前端·程序人生·ui·rust·开源·github