app.js 里面引入路由,app.router(require(‘./router’).default);
    router.js 路由配置,RouterConfig

    1. import { Router, Route, Switch } from 'dva/router';
    2. import Home from './routes/Home';
    3. import User from './routes/User';
    4. import List from './routes/List';
    5. function RouterConfig(props) {
    6. const { history, app } = props;
    7. console.log('app', Object.keys(app))
    8. return (
    9. <Router history={history}>
    10. <Switch>
    11. <Route path="/" exact component={Home} />
    12. <Route path="/" exact render={attrs => <Home {...attrs} />} />
    13. <Route path="/user" exact component={User} />
    14. <Route path="/list" exact component={List} />
    15. </Switch>
    16. </Router>
    17. );
    18. }
    19. export default RouterConfig;