小编And*_*uca的帖子

使用可选路径AND可选参数对路由器4进行反应

需要声明包含字符串和参数的可选路径
现在我有了这个路径

<Route exact path="/tasks/:id" render={(props) => (
  <AsyncTask {...props} profile={this.state.profile} />
)} />
Run Code Online (Sandbox Code Playgroud)

我需要

/tasks/:id/notification/:notificationId
Run Code Online (Sandbox Code Playgroud)

在哪里notification/:notificationId可选
我尝试以这种方式添加它,但它不起作用

/tasks/:id/(notification/:notificationId)?
Run Code Online (Sandbox Code Playgroud)

我需要知道我是否来自通知链接,将其标记为已读.

这很有效

/tasks/:id/(notification)?/:notificationId?
Run Code Online (Sandbox Code Playgroud)

但它没有匹配和路径 notificationId

reactjs react-router

11
推荐指数
1
解决办法
3106
查看次数

标签 统计

react-router ×1

reactjs ×1