react集成react-router
2019-08-12 本文已影响0人
蜗牛_3c49
先安装:
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:{}中间是路由到达的组件