自定义字段排序

//排序方法
multisort(array, ...compairers) {
    return array.sort((a, b) => {
      for (const c of compairers) {
          const r = c(a, b);
          if (r !== 0) {
              return r;
                  }
          }
     });
},
//设置排序字段
this.multisort(pageList,    //data数组
              (a, b) => b.date - a.date,
              (a, b) => b.userNum - a.userNum,
              (a, b) => b.succUserRatio - a.succUserRatio);

猜你喜欢

转载自www.cnblogs.com/minjh/p/9068171.html