1

我正在使用 Meteor 1.2.1 并且遇到了 FlowRouter 的问题。我在 routes.jsx 中声明了一个“/”路由,它在 MainLayout 中呈现了我的 Walls 组件。

我添加了第二条路线“/brews”和一个 Brews 组件,当我转到 localhost:3000/brews 时出现此错误:

Exception from Tracker recompute function:
debug.js:41 ReferenceError: Brews is not defined
    at FlowRouter.route.action [as _action] (router.jsx:9)
    at Route.callAction (route.js:51)
    at router.js:447
    at Object.Tracker.nonreactive (tracker.js:589)
    at router.js:431
    at Tracker.Computation._compute (tracker.js:323)
    at Tracker.Computation._recompute (tracker.js:342)
    at Object.Tracker._runFlush (tracker.js:481)
    at Object.Tracker.flush (tracker.js:441)
    at Router._invalidateTracker (router.js:489)

这是代码:

**router.jsx***

FlowRouter.route('/', {
  action() {
    ReactLayout.render(MainLayout, { content: <Wall /> });
  }
});

FlowRouter.route('/brews', {
  action() {
    ReactLayout.render(MainLayout, { content: <Brews />});
  }
});



***wall.jsx*** *** This Renders fine ***

Wall = React.createClass({
  render() {
    return (
      <div className="footer">
        <h1>Welcome to the Wall!</h1>
      </div>
    )
  }
});


***brews.jsx***

Brews = React.createClass({
  render() {
    return (
      <div className="footer">
        <h1>Welcome to the Wall!</h1>
      </div>
    )
  }
});


***main.jsx***

MainLayout = React.createClass({
  render() {
    return (
      <div>
        <Header />
        <div className="container">
          {this.props.content}
        </div>
        <Footer />
      </div>
    )
  }
});



***main.html***

<head>
  <title>Example React App</title>
</head>

<body>
  <div id="react-root"></div>
</body>
4

0 回答 0