desc是升序还是降序,js数组sort升序降序
//html divid=' test ' input type=' text ' placeholder='关键字' v-model=' searchname '/ulliv-for=' (索引) index ----- { p.age }/Li/ul button @ click button button @ click=' set ordertype (2) '年龄降序/button button @ click=' set orde divscriptsrc=avascript ' charset=' utf-8 '/script//jsscriptnewvue (El : ' # test ),data: ) persons: ) age:11}、{name:'Timi ',age:23}、{name3360'XBC ',age33609}} 1为升序,2为降序,1 },computed : { filted } ordertype }=this console.log (this ) console.log ) searchname (console.log ) persons ) console.log (ordertype )/==-1排序if(ordertype!==0) ) fpersons.sort(function(p1,p2 ) ) /在负数P1之前,将正数p2返回到之前//1表示升序,表示2降序if (ordertype==2) returnp