sort排序

后端返回字段,前端用sort进行正序排序

  init() {
      this.formLoading = true;
      GetAllGalleryTestLevelTypeInfos()
        .then((res) => {
          res.data.sort((a,b)=>{
            return a.serial_number-b.serial_number
          })
          this.data = res.data;
          console.log( this.data," serial_number");
          this.formLoading = false;
        })
        .catch((err) => {
          console.log(err);
          this.formLoading = false;
        });
    },

你可能感兴趣的:(javascript)