js递归树,修改树的key

176 阅读1分钟
			mapTree (org) {
			    const haveChildren = Array.isArray(org.children) && org.children.length > 0;
			    return {
			        text: org.title,
			        value: org.value,
			        data: {...org},
			        children: haveChildren ? org.children.map(i => this.mapTree(i)) : []
			    };
			},

		async getRegion(){
				const res = await getRegion()
				console.log(res)
				this.localdata  = res.data.map(org => this.mapTree(org));
				console.log(this.localdata)
			},