当前位置:网站首页>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
边栏推荐
- 信息学一本通-小球
- 共用数据的保护
- 【UDS统一诊断服务】一、诊断概述(1)— 诊断概述
- Initialization of classes and objects (constructors and destructors)
- File viewing commands and user management commands
- [UDS unified diagnosis service] i. diagnosis overview (1) - diagnosis overview
- 特效案例收集:鼠标星球小尾巴
- Informatics one book pass - small ball
- 汇编 32位无符号加法计算器
- 赛氪-zeal
猜你喜欢
OpenCV使用 GenericIndex 进行 KNN 搜索
【UDS统一诊断服务】(补充)五、ECU bootloader开发要点详解 (2)
信息学一本通-小球
FOC电机库 定点PID代码分析
Collection of practical tips for C language (continuously updated)
基于TensorFlow的线性回归实例
基于VGG卷积神经网络的图像识别代码实现
[UDS unified diagnostic service] IV. typical diagnostic service (2) - data transmission function unit
[UDS unified diagnosis service] i. diagnosis overview (1) - diagnosis overview
CUDA project encountered a series of compilation problems after changing the environment (computer)
随机推荐
ES6
CUDA环境安装
[UDS unified diagnosis service] IV. typical diagnosis service (3) - read fault information function unit (storage data transmission function unit)
FOC SVPWM函数PWMC_SetPhaseVoltage解析
QT icon application
修改注册表的值
C语言的浪漫
Modify registry values
Log writing method (with time)
CUDA project encountered a series of compilation problems after changing the environment (computer)
[ThreadX] ThreadX source code reading plan (I)
CUDA environment installation
友元函数,友元类,类模板
cv_bridge 与opencv 版本不匹配的解决
提交本地仓库并同步码云仓库
Quaternion multiplication
Protection of shared data
C51/C52 特殊功能寄存器表
Wechat applet request encapsulation
三极管原理及特性分析