【发布时间】:2013-07-22 13:04:36
【问题描述】:
当我如下定义变量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');
问题:为什么它必须是全局范围的?
【问题讨论】:
标签: javascript meteor