Skip to content

Latest commit

 

History

History
37 lines (23 loc) · 627 Bytes

react_路由的基本使用.md

File metadata and controls

37 lines (23 loc) · 627 Bytes

react-router-dom

route路由

router路由器

// React-Router
<Link className="list-group-item" to="/about">About</List>

<Route path="/about" component={About}/>

import {BrowserRouter} from 'react-router-dom'
<BrowserRouter>
 <App/>
</BrowserRouter>

<HashRouter></HashRouter>
  1. 明确好界面中的导航区,展示区
  2. 导航区的a标签改为Link标签
<Link to="/xxx">Demo</Link>
  1. 展示区写Route标签进行路径的匹配
<Route path="/xxx" component={Demo}/>
  1. <App>的最外侧包裹了一个<BrowserRouter><HashRouter>