在使用publish时 需要现在工程目录下运行 meteor remove autopublish,
subscribe缓存在客户端的数据集合,读取操作不再需要对服务端进行往返操作。并限制缓存中的内容,在客户端对集合中的每个文档的查询,仅在服务发布到客户端的文档集合中。
eg:
waitOn() {
return [
Meteor.subscribe('matchById', this.params.matchId),
Meteor.subscribe('matchsubById', this.params.subId),
];
},
Meteor.publish('matchById', function (id) {
return Matches.find({ _id: id });
});
Meteor.publish('matchsubById', function (id) {
return GameSubs.find({ _id: id });
});
waitOn 缓存数据,将上一个页面的数据缓存至当前页面;
data() {return Matches.findOne(this.params.matchId); }
使用data()时,数据在当前页面的this.data属性中可以被查找到;