Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用react路由器dom v5.0.1获取参数_Javascript_Reactjs_React Router Dom - Fatal编程技术网

Javascript 如何使用react路由器dom v5.0.1获取参数

Javascript 如何使用react路由器dom v5.0.1获取参数,javascript,reactjs,react-router-dom,Javascript,Reactjs,React Router Dom,在获取参数之前,如何使用react router dom v5.0.1获取参数,但现在无法获取参数,问题是什么 <BrowserRouter> <Route path='/' exact component={Login} /> <Route path='/register' component={Register} /> <Route path='/home' component={Home} />

在获取参数之前,如何使用react router dom v5.0.1获取参数,但现在无法获取参数,问题是什么

<BrowserRouter>
      <Route path='/' exact component={Login} />
      <Route path='/register' component={Register} />
      <Route path='/home' component={Home} />
      <Route path='/all/merchant' component={AllMerchant} />
      <Route path='/detail/merchant/:id_merchant' exact component={DetailMerchant} />
      <Route path='/detail/merchant/promo/:id_merchant' component={MerchantByPromo} />
      <Route path='/promo/voucher/by/merchant/' component={MerchantByPromoDetail} />
      <Route path='/all/category' component={Category} />
      <Route path='/category/id/:category_id' component={CategoryById} render = {props => <CategoryById {...props} key={this.props.match.params} /> }/>
      <Route path='/promo/grid/view' component={PromoGridView} />
      {/* params not found */}
      <Route path='/promo/grid/view/by/category/:category_id' component={AllPromoGridView} />
      <Route path='/detail/promo/:voucher_id/category_id/:category_id' component={PromoGridViewDetail} />
      {/* params not found */}
      <Route path='/account' component={Account} />
    </BrowserRouter>

}/>
{/*未找到参数*/}
{/*未找到参数*/}

根据react路由器,它应该可以通过道具
match
组件中访问:

例如:

// the route
<Route path="/:id" component={Child} />

/*
...
*/ 

//the component
function Child({ match }) {
  return (
    <div>
      <h3>ID: {match.params.id}</h3>
    </div>
  );
}
//路由
/*
...
*/ 
//组件
函数子项({match}){
返回(
ID:{match.params.ID}
);
}

您能澄清一下您的问题吗?您想问什么还不清楚