0

我使用来自 GitHub 存储库的最新 ember-latest.js。

当我尝试使用计算属性时,它不起作用。但是,当我使用Ember.computed它而不仅仅是一个函数时,它会起作用。

我想也许原型扩展被禁用了。但是Em.EXTEND_PROTOTYPEStrue。那么为什么它不起作用呢?

http://jsfiddle.net/Krutius/TmYuS/

HTML / 车把

<script type="text/x-handlebars" data-template-name="test">
    {{test}}
</script>​

Javascript

App = Em.Application.create({});

Em.View.create({
    templateName: 'test',
    test: function() {
        return("true")
    }
}).append();​
4

1 回答 1

2

要将函数标记为计算属性,您必须添加.property()到您的定义中,请参阅http://jsfiddle.net/pangratz666/zssx4/

Em.View.create({

    test: function() {
        return true;
    }.property()

}).append();​

查看http://emberjs.com/documentation/#toc_ember-js-at-a-glance中的“计算属性”

于 2012-07-03T10:10:49.173 回答