1

ゲームがあり、冒険が残っている場合にテンプレートをレンダリングするシステムが必要です。

Meteor.methods({


  adventure: function () {
    if(Meteor.user().adv > 0)
    {
    Meteor.users.update({_id: this.userId}, {$inc: {'adv': -1 }}); 
    this.render('adv');
    }
    else
    {
    this.render('noadventures');
    }
  },      
})

adv という名前のテンプレートがありますが、読み込まれません。

4

2 に答える 2

1

Blaze.render または Blaze.renderWithData を使用します。次のようにします。

Meteor.methods({


  adventure: function () {
    if(Meteor.user().adv > 0)
    {
    Meteor.users.update({_id: this.userId}, {$inc: {'adv': -1 }}); 
       Blaze.render(Template.adv, $('body').get(0);
    }
    else
    {
       Blaze.render(Template.noadventures, $('body').get(0);
    }
  },      
})

これでもっと多くのことができます -ドキュメントはかなり良いです。

于 2015-03-06T19:15:27.063 に答える