我有以下代码。我正在获得组件。但是,不会渲染routes.js中指定的默认路由。我在运行代码时没有收到任何错误。谁能告诉我哪里错了?
这是index.js文件的代码:
var React = require('react');
var ReactDOM = require('react-dom');
var Router = require('react-router');
var routes = require('./routes');
var RouterStore = require('./stores/RouterStore');
var router = Router.create({routes: routes, location: Router.HistoryLocation, scrollBehavior: Router.ScrollToTopBehavior});
RouterStore.set(router);
router.run(function(Root){
ReactDOM.render(
<Root flux={flux}/>,
document.getElementById('myApp')
);
});
以下是myapp.js文件的代码:
var React = require('react');
var Fluxxor = require('fluxxor');
var RouteHandler = require('react-router').RouteHandler;
var Nav = require('./nav');
var myApp = React.createClass({
render: function() {
return (
<div>
<Nav />
<RouteHandler />
</div>
);
}
})
module.exports = myApp;
这是routes.js文件的代码:
var React = require('react');
var Router = require('react-router');
var Route = Router.Route;
var DefaultRoute = Router.DefaultRoute;
var myApp = require('./components/myapp');
var Progress = require('./components/progress');
function LoadingWrapper(component) {
return React.createClass({
mixins:[component.Mixin],
renderUnavailable : function(){
return (<Progress />);
}
});
}
var routes = (
<Route handler={myApp}>
<DefaultRoute name="home" handler={LoadingWrapper(require('react-proxy?name=featured!./components/featured/home'))} />
</Route>
);
module.exports = routes;