声明数组:testlist:["002","001","003"]
想实现效果进行排序:testlist:["001","002","003"]
<script> export default { methods:{ dy() { this. sortByKey(this.testlist); conslole.log(this.testlist); } } } </script>
调用代码为
<script> export default { methods:{ sortByKey(array){ return array.sort(function(a,b){ return(a<b)?-1:(a<b?1:0) }) } } } </script>