-1

ブラウザ:

Colors.insert({名前: "緑"});

ReferenceError: 色が定義されていません [このエラーで中断]

var Colors = new Meteor.Collection("colors");
Colors.insert({name: "Red"});
var lists = new Meteor.Collection("Lists");

if (Meteor.isClient) {
  Template.hello.greeting = function () {
    return "Welcome to LendLib.";
  };

  Template.hello.events({
    'click input' : function () {
      // template data, if any, is available in 'this'
      if (typeof console !== 'undefined')
    myColor=Colors.find({}).fetch();
        console.log("You pressed the button" + myColors);
    }
  });
}

エラーはどこにありますか? http://kf40.ru:3000でのテスト

4

1 に答える 1

0

0.6 より後の Meteor バージョンでは、ローカル JavaScript 変数がカプセル化されているため、変数が定義されたファイルからのみアクセスできます。これが、ターミナルからコレクションにアクセスできない理由です。

グローバルにすることでうまくいくはずです:

Colors = new Meteor.Collection("colors");
于 2013-04-27T13:49:23.523 に答える