多条路线后的Meteor Tracker错误

时间:2016-07-21 18:27:26

标签: meteor iron-router meteor-blaze

当运行特定路线时,我收到错误(见下文),但是只有在运行此路线之前我已经运行了一条或多条其他路线。这些其他路线是什么并不重要。因此,如果我重新加载主页,然后单击此路线,没有错误。但是,如果我重新加载回家,转到任何其他路线,然后问题,我得到这个错误:

  

Tracker重新计算函数的异常:undefined debug.js:43   错误:{{#each}}目前只接受数组,游标或falsey   值。       在badSequenceError(http://localhost:3000/packages/observe-sequence.js?hash=550c39b36ab0e65194ea03cdc7ecbe99dcdd07f6:174:10)       在http://localhost:3000/packages/observe-sequence.js?hash=550c39b36ab0e65194ea03cdc7ecbe99dcdd07f6:139:17       at Object.Tracker.nonreactive(http://localhost:3000/packages/tracker.js?hash=f525263111eb9d90f4ce1ad064f97aca4a6c1b07:631:12)       在http://localhost:3000/packages/observe-sequence.js?hash=550c39b36ab0e65194ea03cdc7ecbe99dcdd07f6:116:15       在Tracker.Computation._compute(http://localhost:3000/packages/tracker.js?hash=f525263111eb9d90f4ce1ad064f97aca4a6c1b07:339:36)       在新的Tracker.Computation(http://localhost:3000/packages/tracker.js?hash=f525263111eb9d90f4ce1ad064f97aca4a6c1b07:229:10)       在Object.Tracker.autorun(http://localhost:3000/packages/tracker.js?hash=f525263111eb9d90f4ce1ad064f97aca4a6c1b07:604:11)       在Object.observe(http://localhost:3000/packages/observe-sequence.js?hash=550c39b36ab0e65194ea03cdc7ecbe99dcdd07f6:113:31)       在 。 (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2763:43)       在fireCallbacks(http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1955:26)   未定义

我的路由器代码:

Router.route('/exercises', {

  name: 'exercises',

  waitOn: function() {
    this.exercisesSub = Meteor.subscribe('exercises');
    this.progressSub = undefined;

    if (Meteor.userId() && Meteor.user() && Meteor.user().emails[0].verified) {
      this.progressSub = Meteor.subscribe("progress", Meteor.userId());
    }

    return [this.exercisesSub, this.progressSub];
  },

  data: function() {

    if (this.exercisesSub.ready()) {

      if (this.progressSub === undefined || this.progressSub.ready()) {

        var data = {
          subHeader: 'Exercises',
          exercises: Exercises.find({}, {sort: {order: 1}}),
        };

        if (this.progressSub !== undefined) {
          data.progress = Progress.findOne({});
        }

        return data;
      }
    }
  }

});

我的HTML:

<template name="exercises">

      {{#each exercises}}

      <exercise id="{{_id}}">
        <h2>{{name}}</h2>
        <completedBox></completedBox><completedBox></completedBox><completedBox></completedBox>
        <description>{{description}}</description>
        <criteria>Criteria: <b>{{criteria}}</b></criteria>
        Highest score: <score>0%</score>
        {{>button name="launch" text="LAUNCH"}}
      </exercise>

      {{/each}}

</template>

返回的集合Exercises包含相同的数据,有或没有错误,但由于某种原因,如果我加载了以前的路由,Meteor不会看到该数据。有什么想法吗?

0 个答案:

没有答案