0

我将 React 0.13.3 与 Webpack 1.9.5 和 traceur-loader 0.6.3 一起使用(之前尝试过 babel-loader),在 DefaultRoute 'Cannot call a class as a function' 中得到 _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'));
    });

以前有人遇到过这个问题吗?

4

1 回答 1

0

原来我使用的是旧的this.props.activeRouteHandler()而不是<RouteHandler/>在我的应用程序和主页组件中,它们是顶级路由。多哈。

正确的语法示例在这里http://rackt.github.io/react-router/

于 2015-05-13T13:52:55.107 回答