vue 表格列日期排序

效果圖

後臺傳的是日期格式,所以需要先轉換時間戳再轉換爲日期。

response.data是所有後臺數據,jsEvaluationTime是日期字段。

checkData(){
  let type = 0;
  let url = SUPPLIERREQUESTPREFIXLIU + '/contract/findScoreDetil?type='+ type
  this.$http.get(url).then(function(response){
    if(response.status === 200){
      // 評價時間排序
      response.data.sort((a, b) => new Date(a.jsEvaluationTime).getTime() - new Date(b.jsEvaluationTime).getTime())

      this.list = response.data
    }
  },function(){
    this.$Message.error('數據獲取失敗,請檢查接口是否正常!');
  })
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章