初识react:
1.react脚手架建项目:
npm install -g create-react-app
create-react-app react-app
cd react-app
2、官网熟悉语法:https://doc.react-china.org/
3、React-router4: https://www.jianshu.com/p/e3adc9b5f75c/
npm install react-router-dom
router组件中: import { BrowserRouter, Route, Link } from "react-router-dom"
link导航,to指定路径,route指定要导航的组件,exact用于精准匹配路径
<BrowserRouter>h5 history Api的高阶组件,保证ui界面和url保持同步
<Route>当前页面的访问地址与Route上的path匹配时渲染出对应的ui界面(自带render methid props)
<NavLink>是<Link>的特殊版,页面导航所准备,表示当前导航有激活状态:
activeClassName: string(激活时应用的样式名),activeStyle: object(直接写style)
isActive: func 决定导航是否激活,或在激活时触发某事件
exact: route属性,react路由会匹配所有匹配到的路由组件.(exact为bool值,为true表示严格匹配,false正常匹配)
match对象: match是匹配路径参数的对象,有url path isExact属性