首页 > 代码库 > es6 递归 tree

es6 递归 tree

function loop(data) {
		let office = data.map(item => {
			if (item.children) {
				if(item.type == ‘1‘ ||item.type == ‘2‘) {
					item = {...item,disabled:true,children:loop(item.children)}
					return item
				}
			}
		})
		return office
	}
	let officeDataTree = loop(officeData)

  

es6 递归 tree