码迷,mamicode.com
首页 > 编程语言 > 详细

返回数据-----数组处理

时间:2019-07-13 19:52:39      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:let   string   col   div   ace   bsp   重构   啊啊啊   i++   

一:数组重构,将返回的数组重构成自己想要的结构;

//后台返回的数据
var dataArr = {
    [{ "id": 1799, "activity_name": "小彬彬啊啊啊", "group_num": 1, "group_member_num": 0 }, { "id": 1800, "activity_name": "中华人民共和国测试部", "group_num": 1, "group_member_num": 0 }, { "id": 1803, "activity_name": "慕容", "group_num": 1, "group_member_num": 0 }, { "id": 1806, "activity_name": "姜致斌测试", "group_num": 1, "group_member_num": 0 }, { "id": 1807, "activity_name": "姜大肥", "group_num": 1, "group_member_num": 0 }] }
//转换
let ydata = [];
let xdata = [];
for (let i = 0; i < dataArr.length; i++) {
ydata[i] = {
name: dataArr[i].activity_name,
value: dataArr[i].group_num
};
xdata[i] = dataArr[i].activity_name;
}

 


二:数组去重,排序,获取最大值;
三:数组日期处理

var dataTime = "20190713".replace(/^(\d{4})(\d{2})(\d{2})$/, "$1-$2-$3");
alert(dataTime);//2019-07-13

//日期处理
var time = "21090713"
var dataTime2 = time.toString().replace(/^(\d{4})(\d{2})(\d{2})$/, "$2-$3");
alert(dataTime2);//07-13

 

返回数据-----数组处理

标签:let   string   col   div   ace   bsp   重构   啊啊啊   i++   

原文地址:https://www.cnblogs.com/alizhi/p/11181778.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!