leiyanting

导航

 

2022年1月10日

摘要: 1.一般写在所有路由注册的最下方,当所有路由都无法匹配时,跳转到Redirect指定的路由 2.具体编码: <Switch> <Route path="/about" component={About}/> <Route path="/home" component={Home}/> <Redire 阅读全文
posted @ 2022-01-10 20:12 leiyanting 阅读(890) 评论(0) 推荐(0)
 
摘要: 1.默认使用的是模糊匹配(简单记:【输入的路径】必须包含要【匹配的路径】,且顺序要一致) 2.开启严格匹配:<Route exact={true} path="/about" component={About}/> 3.严格匹配不要随便开启,需要再开,有些时候开启会导致无法继续匹配二级路由 例子如下 阅读全文
posted @ 2022-01-10 20:09 leiyanting 阅读(225) 评论(0) 推荐(0)
 
摘要: 1.public/index.html 中 引入样式时不写 ./ 写 / (常用) 2.public/index.html 中 引入样式时不写 ./ 写 %PUBLIC_URL% (常用) 3.使用HashRouter (实际开发不会使用) 阅读全文
posted @ 2022-01-10 19:57 leiyanting 阅读(88) 评论(0) 推荐(0)
 
摘要: 1.通常情况下,path和component是一一对应的关系。 2.Switch可以提高路由匹配效率(单一匹配)。 Switch只显示匹配到的第一个路由 import React,{Component} from 'react'; import {HashRouter as Router,Route 阅读全文
posted @ 2022-01-10 19:38 leiyanting 阅读(271) 评论(0) 推荐(0)