gpt4 book ai didi

javascript - Ember 排序不起作用?

转载 作者:行者123 更新时间:2023-12-03 10:47:03 25 4
gpt4 key购买 nike

我正在使用 ember js。

ac = [
{"name" : "Arasad", "price": 350.50},
{"name" : "Brasad", "price": 350.50},
{"name" : "Crasad", "price": 350.50},
{"name" : "Corasad", "price": 350.50},
{"name" : "Cddasad", "price": 350.50},
{"name" : "Dcprasad", "price": 350.50},
{"name" : "Ewasadrrrrrrr", "price": 350.50},
{"name" : "Wrasad", "price": 350.50},
{"name" : "Axrasad", "price": 350.50},
{"name" : "Sxasad", "price": 350.50},
{"name" : "Weasad", "price": 350.50},
{"name" : "Saasad", "price": 350.50},
{"name" : "prasad", "price": 350.50}
]
abc = Ember.ArrayController.create({
model: ac.sortBy('name'),
sortProperties: ['price'],
sortAscending: false
})

排序后,我打印以下元素。abc.toArray()[0]对象{名称:“Dcprasad”,价格:350.5,ember_meta:元}

有什么建议吗,如何对 ember js 中的对象数组进行排序?

实际上我真正的要求是按价格和名称排序。价格最高的排在前面,如果价格相等则按名称升序排序。

谢谢,普拉萨德。

最佳答案

这篇文章应该会有帮助:Ember - sort array by multiple properties in multiple directions

另外,这里有一个 jsbin 详细说明:http://emberjs.jsbin.com/cevivahiso/14/edit

关于javascript - Ember 排序不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28535151/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com