【发布时间】:2012-01-19 08:30:15
【问题描述】:
我正在尝试将 CoffeeScript 与 Backbone.js(通过 Brunch)一起使用,并且我想在我的模型中实现一个保存功能,但它拒绝编译,我一直无法弄清楚原因。我需要将参数传递给保存函数并实现回调。
下面的代码在第二行给出了Unexpected ':' 错误,但我不知道为什么:
class exports.Tag extends Backbone.model
defaults:
id: null
tagId: null
found: false
location: "Not yet found..."
finders: []
pointValue: 0
unlockCode: ""
verifyCode = ( code ) ->
@save { tagId: @get 'tagId', unlockCode: code },
success: ( model, response ) ->
@trigger 'verifySuccessful', response
error: ( model, response ) ->
@trigger 'verifyFailed', response
任何帮助表示赞赏...谢谢!
【问题讨论】: