下面的这个数据
list下面有四个数组
每组数组是个{}
每组下面都有个pictureUrl和tagGroups
tagGroups下面又有一堆数组
每组数据下面又是一堆{}
现在的显示方法是把每个pictureUrl都显示出来
然后在给他对应的traGroups下面的tagName显示到pictureUrl上
这样要怎么对应
{
"success": true,
"msg": "操作成功",
"data": {
"list": [
{
"pictureUrl": "/201604/45A343F8D754468E8963FE02624A7177.jpeg",
"tagGroups": [
[{"tagName": "滋养修护"},{"tagName": "ElizabethArden/雅顿"}],
[{"tagName": "美白"}]
]
},
{
"pictureUrl": "/201604/45A343F8D754468E8963FE02624A7177.jpeg",
"tagGroups": [
[{"tagName": "ElizabethArden/雅顿"}],
[{"tagName": "美白"}]
]
},
{
"pictureUrl": "/201604/FCB3B6D6DFC0462689CD975BDF518024.jpeg",
"tagGroups": [
[{"tagName": "SULWHASOO/雪花秀"}],
[{"tagName": "补水"}],]
]
},
{
"pictureUrl": "/201604/F871063AF6004712B2FB6762790F39A4.jpeg",
"tagGroups": [
[{"tagName": "Estee Lauder/雅诗兰黛"},{"tagName": "修护"},{"tagName": "保湿抗皱"}]
]
}
]
}
}
var list = data['data']['list'],
urlTagMap = {};
for(var k in list) {
var picUrl = list[k]['pictureUrl'];
urlTagMap[picUrl] = urlTagMap.hasOwnProperty(picUrl) ? urlTagMap[picUrl] : [];
list[k]['tagGroups'].forEach(function(tagList) {
tagList.forEach(function(tag) {
urlTagMap[picUrl].push(tag['tagName']);
});
});
}
console.log(urlTagMap);
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。