Blogger Information
Blog 16
fans 0
comment 1
visits 13047
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
数组对象方法排序
IT浪子走天涯
Original
1823 people have browsed it

computed:{

sortitems:function(){

return this.items.sort(sortNumber);

},

sortStudent:function(){

return sortByKey(this.students,'age');

}

}

}

function sortNumber(a,b){

return a-b;

}

//数组对象方法排序:

function sortByKey(array,key){

return array.sort(function(a,b){

var x=a[key];

var y=b[key];

return ((x<y)?-1:((x>y)?1:0));

});

}


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post