在meteor.js中实现拖放区
我刚刚尝试了下面的代码在meteor.js中实现拖放区,meteor,drag-and-drop,Meteor,Drag And Drop,我刚刚尝试了下面的代码 Template.gallery.events({ 'dropped #dropzone': function(event, temp) { console.log('files dropped'); Images = new FS.Collection("images", { stores: [new FS.Store.FileSystem("images", { path: "~/meteor_upl
Template.gallery.events({
'dropped #dropzone': function(event, temp) {
console.log('files dropped');
Images = new FS.Collection("images", {
stores: [new
FS.Store.FileSystem("images", {
path: "~/meteor_uploads"
})
]
});
FS.Utility.eachFile(event, function(file) {
console.log("each file ...")
var images = new FS.File(file);
Images.insert(images, function(err, fileObj) {
if (!err) {
console.log("inserted without error");
} else {
console.log("there was an error", err);
}
});
});
}
});
如果有任何东西掉入下降区,就会出现这个错误
已删除的文件每个文件
已删除的文件
存储名称已存在:“映像” 出现了一个错误
errorClass{error:404,原因:找不到方法:,详细信息:未定义,消息:“找不到方法[404]”,errorType:“Meteor.error”}
给出一些解决建议在触发事件之前,将以下代码从事件处理程序中移到它将在客户端(或客户端和服务器上)上执行的位置
Images = new FS.Collection("images", { stores: [
new FS.Store.FileSystem("images", { path: "~/meteor_uploads" })
]});
这一行正在抛出第二次执行时显示的错误。在该回溯中,第二次执行在第一次执行等待
映像时触发。insert
回调问题得到解决。如果要调用Images,则当代码移到客户端块之外时,它会起作用。在事件处理程序中的客户端上插入,必须首先在客户端上定义Images
。