先安装:
npm install react-router
npm install react-router-dom
引入:
import {HashRouter,Route,Switch } from 'react-router-dom';
使用:
<HashRouter>
<Switch>
<Route path="/hello" component={hello}/>
<Route path="/world" component={world}></Route>
<Route path="/" component={ini}></Route>
</Switch>
</HashRouter>
ps:{}中间是路由到达的组件
网友评论