as shown in figure
because the first level is written dead, so a fixed array is passed in. However, after writing this, the @ check method cannot print any valid values. May I ask why?
<template>
<div class="switch-change">
<el-tree
:props="propstree"
:load="loadNode"
node-key="id"
ref="tree"
accordion
:expand-on-click-node="false"
highlight-current
lazy
show-checkbox
:default-checked-keys="[3]"
:check-on-click-node="true"
:highlight-current="true"
@check="handle"
>
</el-tree>
</div>
</template>
<script>
export default {
name: "DrillingColumn",
data() {
return {
propstree: {
label: "drillingNum",
children: [],
isLeaf: "leaf"
}
};
},
methods: {
handle: function (data, checkState) {
let nodeData = this.$refs.tree.getNode(data); //
console.log(nodeData,"2222222")
},
//
loadNode (node, resolve) {
// console.log(node, resolve)
//
if (node.level === 0) {
return this.requestTree(resolve)
}
//
if (node.level >= 1) {
// resolve
return this.getIndex(node, resolve)
}
},
//
getIndex (node, resolve) {
this.$post(
`${this.$store.state.u_url}page/riskMonitoring/drillingController/queryDrillingDistinct.do`,
).then(res => {
console.log("", res);
// res.leaf = false;
for (let key in res) {
res[key].leaf = true;
}
return resolve(res);
});
},
//
requestTree (resolve) {
return resolve([{drillingNum:""}])
},
}
}
</script>