我正在尝试对一些项目进行排序(对地图进行排序),我可以成功对其进行排序,但我想根据其属性排除一些项目
现在我根据属性 - 价格这样排序
return (product.attr('active') !== 'f'
}).sort(function(pA,pB){
return pB.attr('price') - pA.attr('price'); });
我想跳过一些基于attr('product_id')
因此列出的product_ids不会进行排序,而是首先返回。
return (product.attr('active') !== 'f'
}).sort(function(pA,pB){
return pB.attr('price') - pA.attr('price'); }).except(pA.attr('product_id') == 5677));
像上面的东西,显然 except 函数不存在。
有没有办法根据 id 等属性从排序中排除某些项目?
Data
Map
active
:
true
brand_id
:
1
categories
:
Map(2) ["All Products", "Snacks", _cid: ".map232", _computedAttrs: {…}, __bindEvents: {…}, _comparatorBound: false, _bubbleBindings: {…}, …]
channel_id
:
1
created
:
"2017-08-14T19:16:56.148029-07:00"
description
:
"Breakfast"
image
:
"/media/333807.png"
name
:
"Breakfast"
price
:
"1"
product_id
:
5677