2013-03-15 49 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