fix(directory-tree): expose scrollTo method. (#6067)

Co-authored-by: tan_qiang <tan.qiang@oushu.io>
pull/6071/head
QiangGuZi 2022-11-01 13:36:24 +08:00 committed by GitHub
parent 639b746ba5
commit 265233c34f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import { conductExpandParent } from '../vc-tree/util';
import { calcRangeKeys, convertDirectoryKeysToNodes } from './utils/dictUtil';
import useConfigInject from '../_util/hooks/useConfigInject';
import { filterEmpty } from '../_util/props-util';
import { ScrollTo } from "../vc-tree/interface";
export type ExpandAction = false | 'click' | 'doubleclick' | 'dblclick';
@ -81,7 +82,11 @@ export default defineComponent({
const cachedSelectedKeys = ref<Key[]>();
const fieldNames = computed(() => fillFieldNames(props.fieldNames));
const treeRef = ref();
const scrollTo: ScrollTo = scroll => {
treeRef.value?.scrollTo(scroll);
};
expose({
scrollTo,
selectedKeys: computed(() => treeRef.value?.selectedKeys),
checkedKeys: computed(() => treeRef.value?.checkedKeys),
halfCheckedKeys: computed(() => treeRef.value?.halfCheckedKeys),