我在运行项目时遇到此错误,有什么想法吗?
错误是:未捕获的TypeError:无法读取未定义的属性'toObjects'。
请参阅以下代码一次:
Members = new Meteor.Collection("members");
if (Meteor.isClient) {
var fileName = '';
Template.hello.events({
'change input': function(ev) {
fileName = ev.currentTarget.files;
console.log("fileName : "+ fileName);
_.each(ev.currentTarget.files, function(file) {
Meteor.saveFile(file, file.name ,file.type);
});
}
});
Template.hello.events({
'click #uploadTestFile':function(e){
console.log("Btn Clicked......."+fileName);
var files = fileName;
for (var i = 0, file; file = files[i]; i++)
{
if (file.type.indexOf("text") == 0)
{
var reader = new FileReader();
reader.onloadend = function (e)
{
var text = e.target.result;
console.log(text)
var all = $.csv.toObjects(text);
console.log(all)
_.each(all, function (entry)
{
Members.insert(entry);
});
}
reader.readAsText(file);
}
}
}
});
Meteor.saveFile = function(blob, name, type, path, callback) {
//Here some code
}
}
我没有任何想法。所以请建议我为此做些什么?