React Router呈现空脚本标记

时间:2015-06-24 00:37:06

标签: reactjs react-router

我试图找出React Router,但是当我加载页面时,我只看到一个空的脚本标记被渲染。我一定做错了什么。我已经按照反应路由器文档页面上的指南进行了操作。

var React = require('react');
var Router = require('react-router');
var Route = Router.Route;
var RouteHandler = Router.RouteHandler;

var About = require('./About');
var Inbox = require('./Inbox');

var routes = (
  <Route handler={App}>
    <Route path="about" handler={About}/>
    <Route path="inbox" handler={Inbox}/>
  </Route>
);

var App = React.createClass({
    render () {
      return (
        <div>
          <h1>App</h1>
          <RouteHandler/>
        </div>
      )
    }
});

Router.run(routes, Router.HashLocation, (Root) => {
    React.render(<Root/>, document.getElementById('app'));
});

1 个答案:

答案 0 :(得分:2)

我明白了。我需要将我的路由变量放在App下面,如下所示:

{{1}}