cmd
npm i react-route react-router react-router-dom --save
import
import { HashRouter,Route, Switch } from 'react-router-dom';
render
let routeArr = [
{route:'/ni',component:Container},
]
return (
<HashRouter>
<Switch>
<Route exact path='/' component={Container}/>
{
routeArr.map(v=><Route key={v.route} path={v.route} component={v.component}/>)
}
{/* <Redirect to="/ni" /> */}
</Switch>
</HashRouter>
)
tips
如果还不清楚或者想交个朋友的同学可以微信联系我:qq981145483(备注:csdn fe)