react路由补充部分(exact、八个路由示例)
来源:互联网 发布:淘宝直播怎么开 编辑:程序博客网 时间:2024/06/06 05:10
1、exact
exact是Route下的一条属性,一般而言,react路由会匹配所有匹配到的路由组价,exact能够使得路由的匹配更严格一些。
exact的值为bool型,为true是表示严格匹配,为false时为正常匹配。
如在exact为true时,’/link’与’/’是不匹配的,但是在false的情况下它们又是匹配的。
一个常用的场景是这样的:
<Route path='/' component={Home} /><Route path='/page' component={Page}>//这种情况下,如果匹配路由path='/page',那么会把Home也会展示出来。
- 1
- 2
- 3
所以我们经常添加exact来解决上述问题。
<Route exact path='/' component={Home} /><Route path='/page' component={Page} />
- 1
- 2
2、下面是八个react路由示例:(github上面)。
git@github.com:liwudi/react-router-demo1.git
git@github.com:liwudi/react-router-demo2.git
git@github.com:liwudi/react-router-demo3.git
git@github.com:liwudi/react-router-demo4.git
git@github.com:liwudi/react-router-demo5.git
git@github.com:liwudi/react-router-demo6.git
git@github.com:liwudi/react-router-demo7.git
git@github.com:liwudi/react-router-demo8.git
使用方式:在根目录下npm install,用于下载依赖的包,然后npm start启动项目。
阅读全文
0 0
- react路由补充部分(exact、八个路由示例)
- react路由补充部分(exact、八个路由示例)
- React路由
- React路由
- react路由
- React路由
- react-router 4.x(路由)
- React-router路由实践
- React-router路由实践
- react-router路由
- react路由学习网站
- React-Router4x 路由
- 20、react之 路由
- React-router路由实践
- react-router 路由匹配
- react-router 路由
- react路由配置
- React学习(六):路由
- FAT12中文件目录项时间、日期对应字节问题
- 神龙云服务器,值得期待
- Android Framework解析
- HDACM 1040 As Easy As A+B
- 1028. 人口普查(20)
- react路由补充部分(exact、八个路由示例)
- mongodb 数据备份与还原操作--备份 还原 导出 导入:CSV,JSON,BOSN,解决中文乱码
- 优秀工程师-category和extensions
- Ompl base state space type:OMPL状态空间类型
- Appium对页面操作汇总
- netty EventLoop 源码分析(一)
- mysql基础操作
- 运用ajax和jquey直接调用Aspx.cs后台的方法
- Swift4.0 WKWebView配置JS调Swift