相关疑难解决方法(0)

Ember计算Coffeescript中的属性

我想在Coffeescript中实现以下Javascript代码

App.ItemView = Ember.View.extend({
    classNameBindings: ['itemId'],
    itemId: function() {
        console.log(this.get('content'));
        return "item-%@".fmt(this.get('content.id'));
    }.property('content.id'),
    templateName: 'item'    
}); 
Run Code Online (Sandbox Code Playgroud)

以下是我目前在coffeescript中所拥有的内容:

App.ItemView = Ember.View.extend(
    classNameBindings: ['itemId']

    itemId: ->
        console.log this.get('content')
        contentId = this.get('content.id')
        "item-#{contentId}");
    .property('content.id')

    templateName: 'item'    
)
Run Code Online (Sandbox Code Playgroud)

我明白了:

Error: Parse error on line 11: Unexpected '.'
Run Code Online (Sandbox Code Playgroud)

问题似乎与点在.property('content.id') .我不知道这是如何转化为Coffeescript的.如何在Coffeescript中正确实现此视图?

coffeescript ember.js

17
推荐指数
1
解决办法
4801
查看次数

标签 统计

coffeescript ×1

ember.js ×1