【发布时间】:2017-09-05 01:05:48
【问题描述】:
现在我正在做“脏”拆分以从 url 获取任何 id。我不知道如何使用反应路由器,我做了这样的事情
this.__isEdit = (this.props.history.location.pathname.indexOf('edit') > -1)
const pathnameArr = this.props.history.location.pathname.split('/')
this.__todoId = pathnameArr[pathnameArr.length - 2] //get second last arr
我的一条路线
<Route exact path='/admin/ad/:id/edit' component={createTodoComponent} />
无论如何我可以改进它的代码?
【问题讨论】:
-
你在使用 Redux 吗?
-
你使用哪个版本的 React-router
-
@ShubhamKhatri v4.
-
@DaleFrancis 是的,但我猜这与 redux 无关?
标签: javascript reactjs redux