"showModule":[{"action_id":"21","action_name":"待办任务","action_type":"1","order":"1","pid":"0"},{"action_id":"20","action_name":"物业资源管理","action_type":"1","order":"2","pid":"0","son":[{"action_id":"22","action_name":"楼栋管理","action_type":"2","order":"1","pid":"20","son":[{"action_id":"23","action_name":"添加","action_type":"3","order":"1","pid":"22"},{"action_id":"24","action_name":"修改","action_type":"3","order":"2","pid":"22"},{"action_id":"25","action_name":"删除","action_type":"3","order":"4","pid":"22"},{"action_id":"31","action_name":"详情","action_type":"3","order":"4","pid":"22"}]},{"action_id":"26","action_name":"房间管理","action_type":"2","order":"2","pid":"20","son":[{"action_id":"27","action_name":"添加","action_type":"3","order":"1","pid":"26"},{"action_id":"28","action_name":"修改","action_type":"3","order":"2","pid":"26"},{"action_id":"29","action_name":"删除","action_type":"3","order":"3","pid":"26"},{"action_id":"30","action_name":"详情","action_type":"3","order":"4","pid":"26"}]}],数据结构是这样的我想处理一下数据结构变成下面这样,应该怎么写呢showModule:{label:action_name,value:action_id,son:[{label:action_name,value:action_id,son:{label:action_name,value:action_id,}},{label:action_name,value:action_id}]}这么写就能循环一级啊在item.son上用map就报错了constmapData=data.showModule.map(item=>({label:item.action_name,value:item.action_id,subModule:item.son}))
繁星淼淼
相关分类