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('数据获取失败,请检查接口是否正常!');
  })
}

 

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