怎么样才能把
var dd =[ [
{
linenId: '2222',
attributeSonName: '布料'
},
{
linenId: '11111',
attributeSonName: '布料'
},
{
linenId: '333',
attributeSonName: '古田路'
},
{
linenId: 'LINENSON002111',
attributeSonName: '皮料'
},
{
linenId: 'LINENSON003111',
attributeSonName: '皮料'
},
{
linenId: '111',
attributeSonName: '渣渣会'
},
{
linenId: '12222',
attributeSonName: '222渣渣会'
}
],
[
{
linenId: '2222',
attributeSonName: '布料'
},
{
linenId: '11111',
attributeSonName: '布料'
},
{
linenId: '333',
attributeSonName: '古田路'
},
{
linenId: '12222',
attributeSonName: '222渣渣会'
}
] ]
如何转化 才能得到下形式 根据attributeSonName
相同然后把lineId
push
到一个数组中
var cc =[ [
{
linenId: [2222,11111],
attributeSonName: '布料'
},
{
linenId: [333],
attributeSonName: '古田路'
},
{
linenId: [LINENSON002111,LINENSON003111],
attributeSonName: '皮料'
},
],
[
{
linenId: [2222,11111],
attributeSonName: '布料'
},
{
linenId: [12222],
attributeSonName: '222渣渣会'
}
] ]
参考一下lodash/groupBy实现