2013-03-15 54 views
0

我有以下收集模型骨干扩展功能错误

define([ 
    'underscore', 
    'backbone', 
    'models/domain' 
], function(_, Backbone, DomainModel){ 
    var DomainCollection = Backbone.Collection.extend({ 
    model : DomainModel, 
    getAll : function() { 
     console.log('test'); 
    }. 
    }); // <--- error here 
    return DomainCollection; 
}); 

它抛出一个犯错或上述规定的行:

SyntaxError: Expected an identifier but found '}' instead

如果我删除getAll功能,它的工作原理。有谁明白为什么会发生这种情况?

+1

是后'GETALL的'.':函数(){的console.log( '试验');}'一个错字? – cheesemacfly 2013-03-15 14:58:19

+0

对不起,修正了。编辑:我拿回来,这是问题。我今天一直在这个时间太长...... – Rikkles 2013-03-15 15:04:00

回答

2
getAll : function() { 
    console.log('test'); 
}. // <---- error here 

应该更像:

var DomainCollection = Backbone.Collection.extend({ 
    model : DomainModel, 
    getAll : function() { 
    console.log('test'); 
    } // no period 
}); 
+0

是的,你说得对,我今天编码时间过长,误以为是逗号。 – Rikkles 2013-03-15 15:06:28

+0

@ Rikkles发生在我们身上。如果你愿意,随意删除这个问题。它可能不会真正帮助未来的游客。你的来电。 – Kyle 2013-03-15 15:10:08

+0

不能这样做,它有答案,不用担心。谢谢。 – Rikkles 2013-03-15 15:19:20