我正在使用最新版本的react-router
(版本 ^3.0.0)。
我用ES5编写了以下路由代码:
routes.js
:
var React = require("react");
var Router = require("react-router");
var AuthorPage = require('./components/authors/authorPage')
var App = require('./components/app')
var Route = Router.Route;
var routes = (
<Route path="/" component={App}>
<Route path="authors" component={AuthorPage}/>
</Route>
);
module.exports = routes;
在另一个名为
main.js
的JS文件中,我执行了以下调用:
main.js
:
var React= require("react");
var ReactDom = require("react-dom");
var Router = require('react-router').Router;
var routes = require('./routes');
ReactDom.render(<Router routes={routes}></Router>, document.getElementById('app'));
当我运行代码时,我在Google Chrome开发者工具中得到以下异常:
Uncaught TypeError: Cannot read property 'getCurrentLocation' of undefined
这是为什么?我缺少了什么?