ike*_*tan 2 javascript model ember.js
我正在尝试在模型中使用计算属性来呈现模板中的数据.这是我模型的片段:
App.ApplicationRoute = Ember.Route.extend({
model: function() {
...
divStyle: function() {
return "height:" + this.get('height') + "px; color:"+ this.get('color') +";";
}.property('height', 'color')
}
}
Run Code Online (Sandbox Code Playgroud)
这是我模板的片段:
{{#each}} <div {{bindAttr style="divStyle"}}</div> {{/each}}
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:"断言失败:属性必须是数字,字符串或布尔值,而不是函数".我正在关注这篇文章:Ember.js在模板中绑定一个css样式,不知何故它不起作用.有任何想法吗?
| 归档时间: |
|
| 查看次数: |
2567 次 |
| 最近记录: |