<el-tree
:data="treeData"
show-checkbox
default-expand-all
node-key="id"
ref="tree"
highlight-current
@check="getHalfCheckEvent"
>
</el-tree>
@check=“getHalfCheckEvent”(当复选框被点击的时候触发)
let checkData = this.$refs.tree.getCheckedNodes();
var arr = [];
checkData .forEach(item => {
if (!item.hasOwnProperty("children")) {
arr.push(item.id);
}
});
最里面的id是唯一不重复的id,不然会报警告,该项一般用于唯一不会重复的id