我正在通过react-router指南(http://rackt.github.io/react-router/)工作,并设置了一个不错的小路由器。但routes路由变量中的Route节点完全忽略了{Application}处理程序,只是直接将Dashboard呈现到页面上,无法控制它的去向。有什么想法吗?
以下是我用作测试的代码:
var React = require("react"),
Router = require("react-router"),
Route = Router.Route,
DefaultRoute = Router.DefaultRoute,
RouteHandler = Router.RouteHandler, // I can comment this out and nothing breaks
App = {
Dashboard: require("./js/components/Dashboard.jsx")
},
routes = (
<Route path="/" handler={Application}>
<DefaultRoute handler={App.Dashboard} />
</Route>
),
// This React component is ignored, even though it's set as the handler in the routes object
Application = React.createClass({
render: function() {
return (
<div>
<h1>THIS TITLE IS NEVER ACTUALLY RENDERED</h1>
{/* The RouteHandler here is just ignored. I can comment it out, and rendering is identical! */}
<RouteHandler />
</div>
)
}
});
Router.run(routes, Router.HistoryLocation, function (RouteHandler) {
React.render(<RouteHandler/>, document.getElementById("app));
});