loading...

vue - 数组里按时间排序

1.把数组里的时间参数转化成值

temp.sorttime = new Date(tempList[i].createTime).getTime();

2.对数组里的值进行排序

list.sort(this.compare("sorttime"));
compare方法
compare(property) {
      return function (a, b) {
        var value1 = a[property];
        var value2 = b[property];
        return value2 - value1;
      };
    }
posted @ 2020-12-27 19:21  robinloveslife  阅读(2283)  评论(0编辑  收藏  举报