当我运行我的应用程序时,我收到以下错误消息
Errors prevented startup:
While processing files with ecmascript (for target web.browser):
client/templates/posts/post_item.js:59:3: Unexpected token (59:3)
Your application has errors. Waiting for file change.
Started MongoDB.
我的代码中提到的部分如下(确切地说是最后一行)
Template.postItem.events({
'click .upvotable': function(e) {
e.preventDefault();
Meteor.call('upvote', this._id);
},
'click .disable': function(e) {
e.preventDefault();
Meteor.call('unupvote', this._id);
}
});//here is the problem
有人可以帮我解决错误吗
如果需要,整个文件都在那里:
Template.registerHelper("isGreaterThanZero", function(array) {
check(array, Array)
if(array.length>0){
return true
}else{
return false
}})
Template.postItem.onCreated(function (){
Meteor.subscribe("tags")
Meteor.subscribe('singlePost', this._id)
})
Template.postItem.helpers({
ownPost: function() {
return this.userId == Meteor.userId();
},
tags: function() {
var arr = [];
if(this.tags){
if (this.tags[0]){
for(var i =0;i<this.tags.length;i++){
if (Tags.find({body: this.tags[i]}).fetch()[0]) {
if(!(Tags.find({body: this.tags[i]}).fetch()[0] in arr)){
arr.push(Tags.find({body: this.tags[i]}).fetch()[0])}}}
return arr} else {
return arr
}
} else {
return arr
}};
Template.postItem.events({
'click .upvotable': function(e) {
e.preventDefault();
Meteor.call('upvote', this._id);
},
'click .disable': function(e) {
e.preventDefault();
Meteor.call('unupvote', this._id);
}
});
答案 0 :(得分:4)