JavaScript   发布时间:2022-04-16  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Ember.JS中的动态计算属性已弃用?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图制作一个垃圾应用程序.我有一个计算属性,控制器如下所示:
// The Controller

Todos.Controller = Ember.Controller.create({

    // ** SNIP ** //

    countCompleted: function()
    {
        return this.get('todos').filterProperty('completed',truE).length
    }.property(),});

// The View

{{Todos.Controller.countCompleted.property}} Items Left

现在我正在关注的教程是使用旧版本的Ember.Js.我已经修复了每个错误,但是这样:

未捕获错误:断言失败:Ember.object.create不再支持定义计算属性.

这样做的另一种方法是什么?

解决方法

计算的属性仅在对象的create()函数中被弃用.如果要创建一个计算属性,则必须先扩展()对象,然后再创建()它.

例如:

// The Controller

Todos.TodosController = Ember.Controller.extend({

    // ** SNIP ** //

    countCompleted: function()
    {
        return this.get('todos').filterProperty('completed',});

// Note the lower case 't' here. We've made a new object
Todos.todosController = Todos.TodosController.create();

// The View


// We reference the created object here (note the lower case 't' in 'todosController')
{{Todos.todosController .countCompleted.property}} Items Left

大佬总结

以上是大佬教程为你收集整理的Ember.JS中的动态计算属性已弃用?全部内容,希望文章能够帮你解决Ember.JS中的动态计算属性已弃用?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。