我正在尝试创建包含可选路由参数和不同固定子路由的组合的路由配置。这行:
routes =[
{
path: "category/:categoryId?", component: ...
},
{
path: "account",
component: Account,
routes: [
{
path: "account/profile",
...
},
{
path: "account/history"
...
}
]
}
]
在这种情况下,如果出现“ account/profile
”和“ account/history
”,我可以传递组件,因为它们是由不同的组件处理的,
但在“ category/:categoryId?
”的情况下,仅参数值会更改,因此可以使用相同的组件,但参数是可选的。
现在我无法弄清楚的是如何使用此配置创建路由,如以下所述:
ReactTraining