dva多层路由设置问题

两层路由:
const routes = [

{
  path: '/dashboard',//第一层路由
  component: App,
  getIndexRoute(nextState, cb) {},
  childRoutes: [{//子路由
    path: 'product',
    getComponent(nextState, cb) {},
  }],
}

]
如果子路由里面再设置子路由该怎么设置呢?

阅读 5.3k
1 个回答

https://github.com/zuiidea/an... 参考一下。。
或者
首先
path: '/',
getChildRoutes(location, callback) {

    require.ensure([], function (require) {
        callback(null, [
            
            require('嵌套路由地址/manager'),
            
        ])
    })
}

然后,嵌套的路由
module.exports = {

path: 'manager',
getComponents(location, callback) {
    console.log("about com");
    require.ensure([], function (require) {
        callback(null, IndexHome);
    })
},
//初始进来跳入模块
indexRoute: {component: require('../containers/TemplateHomeContainer')},
//路径嵌套
getChildRoutes(location, callback) {
    require.ensure([], function (require) {
        callback(null, [
            //模板管理
            {
                path: 'templateManager',
                component: require('组件地址')
            }
            //还想向下嵌套,继续请求下一个router文件
        ])
    })
}

}

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题