[
{
name: '123',
type: 'menu',
children: [{ name: '321', type: 'operation', children: null }],
},
{
name: '456',
type: 'menu',
children: [
{
name: '654',
type: 'menu',
children: [{ name: '546', type: 'operation', children: null }],
},
],
},
];這樣一組數(shù)據(jù)我想通過js 的map 取出所有type = "operation"的name 例如如上數(shù)據(jù)取出來的結(jié)果是['321','546']注意:實際的數(shù)據(jù)可能無線層嵌套
js 的map如何優(yōu)雅的遞歸取數(shù)據(jù)
猛跑小豬
2018-10-24 12:42:15