记录一下 2 种路由写法
- 如下写法,可以通过
/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",
},
},
],
},
- 如下写法,可以通过
/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",
},
},
],
},