递归出树当层级下的所有id

下面是vue项目中的部分代码

getTreeIds(data){
	if(data.children instanceof Array){
		data.children.forEach(item=>{
			this.ids.push(item.id);
			this.getTreeIds(item)
		})
	}
}

this.ids.push(data.id);
this.getTreeIds(data);
发布了142 篇原创文章 · 获赞 20 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_35958891/article/details/105247689