2016-02-08 50 views
0

我无法获得我的索引路由(家庭组件)加载,真的会感谢一些帮助,因为我做错了什么?异步IndexRoute不与反应路由器加载

我routes.js文件看起来像这样

module.exports = <Route 
    path="/" 
    getComponent={(location, cb) => { 
     require.ensure([], (require) => { 
     cb(null, require('./Container')) 
     }) 
    }} 
    getChildRoutes={(location, cb) => { 
     require.ensure([], (require) => { 
     cb(null, require('./Container').childRoutes) 
     }) 
    }} 
    getIndexRoute={(location, cb) => { 
     require.ensure([], (require) => { 
     cb(null, require('./Container').indexRoute) 
     }) 
    }} 
/> 

和我Container.js文件看起来像这样

export default class Container extends Component { 
    render =() => { 
    return <div> 
     {this.props.children} 
    </div> 
    } 
} 

Container.childRoutes = [ 
    <Route 
    path="/:product/get-quote" 
    component={props => <Product productName={props.params.product} {...props} />} 
    />, 
    <Route 
    path="/:product/processing-quote" 
    component={props => <ProcessingQuote productName={props.params.product} {...props} />} 
    /> 
] 

Container.indexRoute = <IndexRoute component={Home} /> 

回答

1

如果您使用的是getChildRoutesgetIndexRoute处理程序,你应该使用PlainRoute配置对象,而不是JSX组件。

+0

更改为Container.indexRoute = {component:Home}'感谢taion – Ally