ES6 对象排序:根据对象属性进行sort排序

sortGoodsByPrice(){
	this.goodsList.sort((a,b)=> b.goods_price - a.goods_price);
},
{
add_time: 1516451096
cat_id: 28
cat_one_id: 1
cat_three_id: 28
cat_two_id: 7
goods_big_logo: "http://image2.suning.cn/uimg/b2c/newcatentries/0070115389-000000000624896755_2_800x800.jpg"
goods_id: 30076
goods_name: "Haier/海尔 SKFR-72LW/10WAC21AU1智能空调柜机大3匹变频一级静音"
goods_number: 100
goods_price: 11999
goods_small_logo: "http://image2.suning.cn/uimg/b2c/newcatentries/0070115389-000000000624896755_2_400x400.jpg"
goods_weight: 100
hot_mumber: 0
is_promote: false
upd_time: 1516451096
}

你可能感兴趣的:(前端,JS高级,es6,前端)