Antd中将table中的数据按时间排序

    技术2022-07-10  99

    最新发布在最上面 放到计算属性中,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 }) } }
    Processed: 0.034, SQL: 9