问题
Tree组件默认无法获取父节点id
解决方案
没有实现按需引入
node_modules->element-ui->lib->element.ui.common.js 25382行修改源码
去掉 includeHalfChecked &&
childNodes.forEach(function (child) {
// if ((child.checked || includeHalfChecked && child.indeterminate) && (!leafOnly || leafOnly && child.isLeaf)) {
// checkedNodes.push(child.data);
// }
if ((child.checked || child.indeterminate) && (!leafOnly || leafOnly && child.isLeaf)) {
checkedNodes.push(child.data);
}
实现按需引入
node_modules->element-ui->lib->tree.js 1051行修改源码
去掉 includeHalfChecked &&
childNodes.forEach(function (child) {
// if ((child.checked || includeHalfChecked && child.indeterminate) && (!leafOnly || leafOnly && child.isLeaf)) {
// checkedNodes.push(child.data);
// }
if ((child.checked || child.indeterminate) && (!leafOnly || leafOnly && child.isLeaf)) {
checkedNodes.push(child.data);
}