有时候需要获取el-tree每个节点的点击状态,可以通过以下方式,其中isCheck类型为布尔值
<el-tree
:data="organizationData"
:props="defaultProps"
:check-strictly="isAssociate"
node-key="organizationId"
:expand-on-click-node="false"
@check="getCurrentNode"
ref="tree"
>
</el-tree>
1.绑定@check事件,我这里是getCurrentNode,函数名自己随便写
2.绑定ref
getCurrentNode(nodeObj, nodeState) {
//判断当前状态是选中还是取消选中
const isCheck = this.$refs.tree.getCheckedNodes().indexOf(nodeObj) > -1
console.log(isCheck)
}