最新发布在最上面 放到计算属性中,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://ipadbbs.8miu.com/read-1677.html