后端给我的数据是这样的:
let obj = [
{
areaName:"华南地区",
cityName:"深圳"
},
{
areaName:"华南地区",
cityName:"广州"
},
{
areaName:"华南地区",
cityName:"海口"
},
{
areaName:"华北地区",
cityName:"黑龙江"
}
];
我该怎么处理才能变成下面这种格式?
{
areaName:"华南地区",
children:[
{
cityName:"深圳"
},
{
cityName:"广州"
},
{
cityName:"海口"
}]
},
{
areaName:"华北地区",
children:[
{
cityName:"黑龙江"
}]
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…