这里有什么问题?
ExecJS :: ProgramError:错误:第11行的解析错误:意外'。'
.coffee
Person = Ember.Object.extend(
firstName: null
lastName: null
fullName: ->
firstName = @get("firstName")
lastName = @get("lastName")
firstName + " " + lastName
.property("firstName", "lastName")
)
原创.js
Person = Ember.Object.extend({
// these will be supplied by `create`
firstName: null,
lastName: null,
fullName: function() {
var firstName = this.get('firstName');
var lastName = this.get('lastName');
return firstName + ' ' + lastName;
}.property('firstName', 'lastName')
});
答案 0 :(得分:0)
调用方法时需要添加大括号。
Person = Ember.Object.extend(
firstName: null
lastName: null
fullName: (->
firstName = @get("firstName")
lastName = @get("lastName")
firstName + " " + lastName
).property("firstName", "lastName")
)
确实,它们在Coffeescript中是可选的,但在这种情况下我认为你需要明确地添加它们。至少这是我编译它的唯一方法。也许Coffeescript专家可以启发为什么。