我开始和Meteor合作,我正在讨论第一期.我想在我的收藏中插入一个项目.我得到以下控制台日志错误.有人可以帮助流星菜鸟吗?
插入失败:找不到方法
这是导致错误的行:
Videos.insert({name: el.value});
Run Code Online (Sandbox Code Playgroud)
我的js文件:
var Videos = new Meteor.Collection("videos");
if (Meteor.isClient) {
Template.videoList.video = function() {
return Videos.find();
}
Template.videoForm.events({
'click button': function(e, t){
var el = t.find("#name");
Videos.insert({name: el.value});
el.value = "";
}
});
}
Run Code Online (Sandbox Code Playgroud)
Boz*_*hao 12
当您尝试Video.insert.Meteor试图在客户端和服务器上同时插入它们.Meteor以这种方式设计它以帮助客户即时反映变化(延迟补偿).
未在服务器上定义视频集合时(不在Meteor.isServer包中或可由服务器访问的文件中).它会抛出你遇到的错误.
如果您只想插入客户端.您可以通过_collection访问它.所以你的insert语句是Videos._collection.insert(values);
您可以在此屏幕上找到更多信息:http://www.eventedmind.com/feed/meteor-anatomy-of-a-collection-insert
| 归档时间: |
|
| 查看次数: |
7993 次 |
| 最近记录: |