Meteor 空格键中是否有存储模板函数返回值的方法?我会更好地解释。
例如,假设我需要知道一个事件是否开始。在 client.js 上,我将拥有:
Template.event.isEventStarted = function(eventId) {
var event = Events.findOne({_id: eventId});
return Events.isStarted(event);
}
假设现在我需要从“事件”模板多次访问“isEventStarted”。我还需要从子模板访问它。显然,每次调用“isEventStarted”时都会执行查询,函数“isStarted”也是如此。他们执行客户端,但我可能有许多带有许多子模板的事件模板。