9

I'm following React Router Guide but I'm not even getting to make the simplest example to work. It says Uncaught ReferenceError: Router is not defined.

I'm including these 3 JavaScript files through cdnjs:

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/JSXTransformer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-router/0.11.6/react-router.js"></script>

And the script the triggers the exception is this:

<script type="text/jsx">
    Router.run(routes, function (Handler, state) {
        React.render(<Handler/>, document.body);
    });
</script>

Am I missing anything? Is Router defined somewhere else? That's weird because it's not stated in the docs.

4

1 回答 1

10

react-router 被定义为全局的 ReactRouter。

你可以这样访问。

<script type="text/jsx">
ReactRouter.run(routes, function (Handler, state) {
    React.render(<Handler/>, document.body);
});
</script>
于 2015-01-19T02:12:13.203 回答