JS使用递归修改多层级数据的key

			cheangeAreaData(data) {
				for (var i = 0; i < data.length; i++) {
					for (var j in data[i]) {
						if (j == "value") {
							data[i]["id"] = data[i].value;
							delete data[i].value;
						}
						if (j == "children") {
							if (data[i].children) {
								if (data[i].children.length > 0) {
									this.cheangeAreaData(data[i].children)
								}
							} else {
								delete data[i].children;
							}

						}
					}
				}
			},
上一篇:递归实现树形图初始化


下一篇:高级前端都写不上来(数组转化成树)