数组中对象去重_[ {1:[ { code:1}, {code:2}, {code:3 } ]}]-CSDN博客

网站介绍:文章浏览阅读2.3k次。数组中对象去重方法应用场景在某些场景下,我们需要将后端获取的一维数组,转化为二维数组的树形结构,才能方便我们使用;比如:城市、区域列表等等场景。示例数据格式如下: arr: [ { code: 1, text: '张三' }, { code: 1, text: '张三' }, { code: 2, text: '李四' }, { code: 1, text: '张三' }, { code: 3, text_[ {1:[ { code:1}, {code:2}, {code:3 } ]}]