VUE中对获取到的数组进行排序
KStarForm.initFormDataAfter = function () { var userAccount = ApplicantAccount; axios.post('/XXXX/Service001', { UserAccount: userAccount, BeginDate: beginDate, EndDate: endDate }).then(function (res) { var resdata = JSON.parse(res.data.data); resdata = resdata.sort(function (a, b) { var x = a["begda"]; var y = b["begda"]; return ((x < y) ? -1 : ((x < y) ? 1 : 0)); }); AbsDate = resdata; }); }
代码里面begda是要进行排序的字段名称