依赖包:

react-router-dom@6.0.0-beta.0

history@5.0.0

 

1. 在入口文件index.tsx中使用 BrowserRouter 包裹app组件

react-routerV6.0的使用

 

2. 组建中配置跳转

react-routerV6.0的使用

 

 

react-routerV6.0的使用

 

 

 

 

 

 

 

3. Link

react-routerV6.0的使用

 

 

4. 嵌套路由

4-1. 从 react-router-dom 中导入Outlet组件(此组件同理vue中的 router-view )

下图为 LayoutComponent  组件代码,匹配到的路由要插入到Outlet组件的位置

react-routerV6.0的使用

 

 

 4-2. 嵌套路由写法

react-routerV6.0的使用

 

相关文章:

  • 2021-03-31
  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
猜你喜欢
  • 2022-12-23
  • 2021-05-13
  • 2021-09-20
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案