当前位置:网站首页>js根据名字将数组对象中名字相同的项组成一个相同的数组
js根据名字将数组对象中名字相同的项组成一个相同的数组
2022-04-23 05:53:00 【Front 小思】
需求:今天遇到一个的是当前定位在广州,根据传广州过去获取会的的所有区的门店数据!设计稿要求:根据所在的区来分类某个区有哪些门店!但是后端就返回一个数组里面有所有的门店!
设计稿:
let tempArr = [];
for (let i = 0; i < that.storeList.length; i++) {
if (tempArr.indexOf(that.storeList[i].area_name) === -1) {
that.afterData.push({
name: that.storeList[i].area_name,
origin: [that.storeList[i]]
});
tempArr.push(that.storeList[i].area_name);
} else {
for (let j = 0; j < that.afterData.length; j++) {
if (that.afterData[j].name == that.storeList[i].area_name) {
that.afterData[j].origin.push(that.storeList[i]);
break;
}
}
}
}
console.log("88888888888888", that.afterData);
搞定!回家吃饭去!!!
版权声明
本文为[Front 小思]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45788691/article/details/122144065
边栏推荐
猜你喜欢
随机推荐
金额输入框,用于充值提现
Quaternion multiplication
赛氪-zeal
[UDS unified diagnosis service] IV. typical diagnosis service (3) - read fault information function unit (storage data transmission function unit)
客户端软件增量更新
HDU-Tunnel Warfare
在visual stdio中运行qt程序
ARM常用汇编指令
修改注册表的值
浮点数双精度,单精度以及半精度知识总结
Running QT program in visual Stdio
CUDA project encountered a series of compilation problems after changing the environment (computer)
Makefile基础、常用函数及通用Makefile
Multibyte and Unicode in VS
软件工程中的十三种文档
POJ-The Unique MST
[UDS unified diagnostic service] II. Network layer protocol (2) - data transmission rules (single frame and multi frame)
友元函数,友元类,类模板
往String原型上封装一个时间戳转日期的方法
Modify registry values