我正在使用React 0.13.3和Webpack 1.9.5以及traceur-loader 0.6.3(之前尝试过babel-loader),在DefaultRoute中使用_classCallCheck()抛出TypeError'不能将类调用为函数' 。我没有看到我将一个类称为函数。这就是我的路线:
var Application = require('./components/Application');
var Home = require('./components/Home');
var About = require('./components/About');
var MainFeedVideos = require('./components/MainFeedVideos');
var MyUploads = require('./components/MyUploads');
...
var routes = (
//logged out content
<Route flux={flux} handler={Application}>
<DefaultRoute handler={Home} />
<Route name='about' handler={About}/>
...
//logged in content
<Route path='/' name='home' handler={Home}>
<DefaultRoute handler={MainFeedVideos} />
<Route name='my-videos' handler={MyUploads}/>
...
</Route>
</Route>);
Router.run(routes, Router.HistoryLocation, function (Handler) {
React.render(<Handler/>, document.getElementById('content'));
});
以前有人遇到过这个问题吗?
答案 0 :(得分:0)
原来我在我的应用程序和主页组件中使用了旧this.props.activeRouteHandler()
而不是<RouteHandler/>
,这是最高级别的路由。卫生署。
在此http://rackt.github.io/react-router/更正语法示例。