Javascript 如何将URL参数传递给ReactJS中的render函数

Javascript 如何将URL参数传递给ReactJS中的render函数,javascript,reactjs,react-router,Javascript,Reactjs,React Router,我有一个类似这样的路由器: <Switch> <Route exact path="/" render={() => <DashboardView {...dashboardViewProps} />} /> <Route path="/blocks" render={() => <BlocksView {...blocksViewProps} />} /> <Route path="/chaincodes

我有一个类似这样的路由器:

<Switch>
  <Route exact path="/" render={() => <DashboardView {...dashboardViewProps} />} />
  <Route path="/blocks" render={() => <BlocksView {...blocksViewProps} />} />
  <Route path="/chaincodes" render={() => <ChaincodeView {...chaincodeViewProps} />} />
  <Route path="/channels" render={() => <ChannelsView {...channelsViewProps} />} />
  <Route path="/network" render={() => <NetworkView  {...networkViewProps} />} />
</Switch>
<Route path="/transactions/:txId" render={() => <TransactionsView {...transactionsViewProps} />} />
constructor(props) {
    super(props);
}

谢谢

路由器组件可以通过路由器道具使用txId,当您通过
渲染道具
渲染组件时,需要将路由器道具传递给组件

<Route path="/transactions/:txId" render={(routerProps) => <TransactionsView {...transactionsViewProps} {...routerProps}/>} />
constructor(props) {
    super(props);
    this.txId = props.match.params.txId
}