打开/ projects时,我看到了ProjectListContainer组件。但是嵌套链接不起作用(/ projects / create)。我该如何解决?我还需要切换嵌套组件。
这是我的路由器:
loadRoutesFrom()
这是我的带有嵌套开关的组件:
$this->app->get("/webhooks/decision", \YoungOnes\ArtisanVeriff\Commands\DecisionWebhookCommand::class);
答案 0 :(得分:1)
尝试
<div className={classes.content}>
<Route exact path={`${match.path}`} component={ProjectsListContainer} />
<Route exact path={`${match.path}/create`} component={CreateProject} />
<Route exact path={`${match.path}/:id`} component={Kanban} />
</div>
答案 1 :(得分:0)
尝试这样
localStorage.setItem("reservations", JSON.stringify(data));
即不带开关。
或使用 return (
<div className={classes.content}>
<Route path={`${match.path}`} component={ProjectsListContainer} />
<Route path={`${match.path}/create`} component={CreateProject} />
<Route path={`${match.path}/:id`} component={Kanban} />
</div>);
https://reacttraining.com/react-router/web/example/nesting
或尝试
useRouteMatch
以上帮助吗?