vue.js 按日期排序处理
var newDate = currentDate.getDate();var data2 = {name:'zk00',age:'26',date_time:newDate};this.students.push(data2);this.students.map(mapItem => {console.log('aaa====...
·
students:[
{name:'cjk',age:'38',date_time:'2020-08-11 08:08:01'},
{name:'xxf',age:'29',date_time:'2020-08-16 11:08:01'},
{name:'zk',age:'36',date_time:'2020-08-13 13:08:01'},
{name:'zk112',age:'32',date_time:'2020-08-10 15:08:01'},
]
var newDate = currentDate.getDate();
var data2 = {name:'zk00',age:'26',date_time:newDate};
this.students.push(data2);
this.students.map(mapItem => {
console.log('aaa====>: ' + JSON.stringify(mapItem))
});
var data = this.students.sort(function(a, b) {
var x = a.date_time.replace(/:/g, "").replace(/-/g, "").replace(" ", "")
var y = b.date_time.replace(/:/g, "").replace(/-/g, "").replace(" ", "")
return ((x<y)?-1:((x>y)?1:0));
});
data.map(mapItem => {
console.log('bbb====>: ' + JSON.stringify(mapItem))
});
更多推荐
已为社区贡献1条内容
所有评论(0)