updateNode (data) {
const fn = function (_treeData) {
if (_treeData.id === data.id) {
_treeData.title = data.name
} else {
if (_treeData.children.length > 0) {
// 开始子节点的循环
for (let j = 0; j < _treeData.children.length; j++) {
fn(_treeData.children[j])
}
}
}
}
// 开始对树根级别的节点循环
for (let i = 0; i < this.treeData.length; i++) {
fn(this.treeData[i])
}
}
用递归方法寻找树的某个子元素,并修改其name的值
最新推荐文章于 2023-06-10 02:08:22 发布