【问题标题】:Meteor.subscribe doesnt workMeteor.subscribe 不起作用
【发布时间】:2016-02-25 06:41:00
【问题描述】:

如果我访问 /whatever/:_id/result 页面,除了静态文本之外,什么都不会呈现。为什么我的 Meteor.subscription 有效?我在这里有什么遗漏吗?

Router.route('/whatever/:_id/result', {
  template: 'result',
  name: 'result',
    data: function(){
      var currentId = this.params._id;
      console.log(currentId);
        return Questions.findOne({_id:currentId});
    },
    WaitOn: function(){
      var currentId = this.params._id;
        return [ Meteor.subscribe('arguments', currentId), Meteor.subscribe('questions',currentId) ]
    },
    onBeforeAction: function(){
      this.next();
    }
});

在我的服务器上我得到了:

Meteor.publish('arguments', function(currentId){
  return Arguments.find({decisionId:currentId});
});

Meteor.publish('questions', function(currentId){
  return Questions.find({_id:currentId});
});

【问题讨论】:

    标签: meteor


    【解决方案1】:

    我认为这是一个简单的错字。

    WaitOn: ...
    

    应该是

    waitOn: ...
    

    使用小写的 w。

    【讨论】:

    • 您应该使用 ESLint - 在我看来,它可以节省大量时间,因为它会在您键入时为您捕获此类错误。
    猜你喜欢
    • 2015-07-31
    • 2017-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-13
    • 1970-01-01
    • 1970-01-01
    • 2016-09-12
    相关资源
    最近更新 更多