vue中根据当前时间进行排序

  computed: {
    newdataList: function() {
      return this.sortKey(this.dataList, "addtime");
    }
  },
  methods: {
    sortKey(array, key) {
      return array.sort(function(a, b) {
        var x = a[key];
        var y = b[key];
        return x > y ? -1 : x < y ? 1 : 0;
      });
    },
}

this.dataList为数据源

猜你喜欢

转载自www.cnblogs.com/huanhuan55/p/10095606.html
今日推荐