lists
当我如下所示定义变量并lists
在控制台中键入时,我收到错误ReferenceError: lists is not defined
var lists = new Meteor.Collection('Lists');
if (Meteor.isClient) {
Template.hello.greeting = function () {
return "my list.";
};
Template.hello.events({
'click input' : function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed the button");
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
只有当我声明lists
为全局变量时它才有效:
lists = new Meteor.Collection('Lists');
问题:为什么它必须是全球范围的?