feat(components): [tree-v2] add setExpendKeys method (#9412)

* feat(components): [tree-v2] add `setExpendKeys` method

* chore: update docs
This commit is contained in:
zz 2022-08-23 09:32:07 +08:00 committed by GitHub
parent 3a6fc23f49
commit 9cb8ce47e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View File

@ -105,6 +105,7 @@ tree-v2/filter
| getCheckedKeys | If the node can be selected (`show-checkbox` is `true`), it returns the currently selected array of node's keys | `(leafOnly: boolean)` |
| setCheckedKeys | set certain nodes to be checked | `(keys: TreeKey[])` |
| setChecked | set node to be checked or not | `(key: TreeKey, checked: boolean)` |
| setExpendKeys | set certain nodes to be expand | `(keys: TreeKey[])` |
| getHalfCheckedNodes | If the node can be selected (`show-checkbox` is `true`), it returns the currently half selected array of nodes | - |
| getHalfCheckedKeys | If the node can be selected (`show-checkbox` is `true`), it returns the currently half selected array of node's keys | - |
| getCurrentKey | return the highlight node's key (undefined if no node is highlighted) | - |

View File

@ -191,6 +191,10 @@ export function useTree(props: TreeProps, emit) {
}
}
function setExpendKeys(keys: TreeKey[]) {
expandedKeySet.value = new Set(keys)
}
function handleNodeClick(node: TreeNode, e: MouseEvent) {
emit(NODE_CLICK, node.data, node, e)
handleCurrentChange(node)
@ -300,5 +304,6 @@ export function useTree(props: TreeProps, emit) {
getNode,
expandNode,
collapseNode,
setExpendKeys,
}
}

View File

@ -93,6 +93,7 @@ export default defineComponent({
getNode,
expandNode,
collapseNode,
setExpendKeys,
} = useTree(props, ctx.emit)
ctx.expose({
@ -110,6 +111,7 @@ export default defineComponent({
getNode,
expandNode,
collapseNode,
setExpendKeys,
})
return {