仅在顶部添加了 1 行代码

Only added 1 line of code at the top

本文关键字:代码 添加 顶部      更新时间:2023-09-26

我不知道我必须做什么才能让它工作,这里是代码:

Songs = new Mongo.Collections("songs");
if (Meteor.isClient) {
  // counter starts at 0
  Session.setDefault('counter', 0);
  Template.hello.helpers({
    counter: function () {
      return Session.get('counter');
    }
  });
  Template.hello.events({
    'click button': function () {
     // increment the counter when button is clicked
      Session.set('counter', Session.get('counter') + 1);
    }
  });
}
if (Meteor.isServer) {
  Meteor.startup(function () {
   // code to run on server at startup
  });
}

这是错误:类型错误:未定义不是函数 在Newapp.js:1:9

我所做的只是添加 1 行。另外,我将如何在浏览器Javascript控制台中运行适当的Javascript代码以将项目插入歌曲集合中。我是初学者。

使用 Mongo.Collection 而不是 Mongo.Collections 。 最后s是没有必要的。