首先,在路由页面,引入了一个组件。RouteDemo 

<BrowserRouter>
        {/* 没通过 <Route /> 匹配路由的  默认拿不到history的*/} 
        <RouteDemo />

        <Switch> 
          <Route path='/table' component={TableDemo}/>
        </Switch>
 </BrowserRouter>

  

在RouteDemo 页面 使用props 是一个空{},如果需要使用路由跳转,如何处理

首先先引入 withRouter 
import { withRouter } from 'react-router-dom'

export default @withRouter  这里我使用的是e7的修饰器, @

  

这样在RouteDemo 就能拿到props了。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-09
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-03-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
相关资源
相似解决方案