我正在使用Meteor 1.4。this.subscribe和Template.instance()。subscribe不起作用
Template.showProducts.onCreated(() => {
var handle = Meteor.subscribe("products");
//not working: var handle = this.subscribe("products");
//not working: var handle = Template.instance().subscribe("products");
Tracker.autorun(() => {
//not working: this.autorun
const isReady = Meteor.ready();
//not working: this.subscriptionsReady()
if(isReady){
const products = Products.find().fetch();
Session.set("prods", products);
}
});
});
如果我使用 「this.subscribe」,我得到:
Uncaught TypeError: _this.subscribe is not a function
如果我使用 「Template.instance()」,我得到:
Cannot read property 'subscriptionsReady' of null