How would you translate this snippet of javascript to coffeescript? Specifically I'm struggling with how to call .property() on the function definition.MyApp.president = SC.Object.create({ firstName: "Barack", lastName: "Obama", fullName: function() { return this.get('firstName') + ' ' + this.get('lastName'); // Call this flag to mark the function as a property }.property('firstName', 'lastName')}); 解决方案 I think this is how you're supposed to write it:MyApp.president = SC.Object.create { firstName: "Barack", lastName: "Obama", fullName: (-> return @get 'firstName' + ' ' + @get 'lastName' # Call this flag to mark the function as a property ).property('firstName', 'lastName')}checkout this link 这篇关于在 coffeescript 中调用函数定义的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-12 01:02
查看更多