때로는 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)
}