The vue2+ant-design-vue tree component selects the node and checks the checkbox

need

The parameters of the selected event in the ant-design-vue tree structure are different from those obtained by the checked event. The requirement is that clicking a tree node has the same operation as checking a check box. Since the parent node id and various operations need to be added when checking, these parameters need to be obtained through the check event and the select event cannot be obtained, so I think of directly operating the click event of the dom element to solve

official document

insert image description here

the code

//html
		<a-tree
            :disabled="!isEdit"
            checkable
            @check="onCheck"
            :checkedKeys="checkedKeys"
            :treeData="treeData"
            @expand="onExpand"
            @select="onTreeNodeSelect"
            :selectedKeys="selectedKeys"
            :expandedKeys="expandedKeysss"
            :checkStrictly="checkStrictly"
          >
       </a-tree>
//js
	//选中事件
    onTreeNodeSelect(selectedKeys, e) {
      //触发复选框的勾选事件
      e.node.$el.childNodes[1].click()
    },

Guess you like

Origin blog.csdn.net/zhongxiajiu/article/details/132691284