app.js 里面引入路由,app.router(require(‘./router’).default);
router.js 路由配置,RouterConfig
import { Router, Route, Switch } from 'dva/router';
import Home from './routes/Home';
import User from './routes/User';
import List from './routes/List';
function RouterConfig(props) {
const { history, app } = props;
console.log('app', Object.keys(app))
return (
<Router history={history}>
<Switch>
<Route path="/" exact component={Home} />
<Route path="/" exact render={attrs => <Home {...attrs} />} />
<Route path="/user" exact component={User} />
<Route path="/list" exact component={List} />
</Switch>
</Router>
);
}
export default RouterConfig;