Antd Design of Vue中將table中的數據按時間排序

最新發布在最上面

放到計算屬性中,dataSource爲後臺獲取的數據,sortedArticles爲table中的數據

computed: {
    sortedArticles: function () {
      return this.dataSource.sort(function (a, b) {
        let aTimeString = a.createTime
        let bTimeString = b.createTime
        aTimeString = aTimeString.replace(/-/g, '/')
        bTimeString = bTimeString.replace(/-/g, '/')
        let aTime = new Date(aTimeString).getTime()
        let bTime = new Date(bTimeString).getTime()
        return bTime - aTime
      })
    }
  }

參考鏈接
https://blog.csdn.net/weixin_35252758/article/details/81045787

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