有没有办法用react-router来模块化你的路线,然后只需导入它们并组装它们?
所以不是这样的:
你可以这样做:
let InboxRoutes = React.createClass({ render: function(){ return (); } });
我明白了:
Warning: Location did not match any routes
一种解决方案是将它们包装在变量中:
let InboxRoutes = () let CalendarRoutes = (/* define routes like above */) let routes = ( ) render(routes, document.getElementById("app")) {InboxRoutes} {CalendarRoutes}
注意:您应该记住放入父路由的render方法 {this.props.children}