fix: expose tree information in the event close #315

This commit is contained in:
Vben 2021-03-02 23:26:11 +08:00
parent 72b42d7b35
commit b6bb81630d
1 changed files with 12 additions and 4 deletions

View File

@ -1,7 +1,16 @@
<script lang="tsx"> <script lang="tsx">
import type { ReplaceFields, Keys, CheckKeys, TreeActionType, TreeItem } from './types'; import type { ReplaceFields, Keys, CheckKeys, TreeActionType, TreeItem } from './types';
import { defineComponent, reactive, computed, unref, ref, watchEffect, onMounted } from 'vue'; import {
defineComponent,
reactive,
computed,
unref,
ref,
watchEffect,
onMounted,
toRaw,
} from 'vue';
import { Tree } from 'ant-design-vue'; import { Tree } from 'ant-design-vue';
import { TreeIcon } from './TreeIcon'; import { TreeIcon } from './TreeIcon';
// import { DownOutlined } from '@ant-design/icons-vue'; // import { DownOutlined } from '@ant-design/icons-vue';
@ -77,9 +86,8 @@
state.selectedKeys = v; state.selectedKeys = v;
emit('update:selectedKeys', v); emit('update:selectedKeys', v);
}, },
onCheck: (v: CheckKeys, e) => { onCheck: (v: CheckKeys) => {
state.checkedKeys = v; state.checkedKeys = v;
console.log(e);
emit('update:value', v); emit('update:value', v);
}, },
onRightClick: handleRightClick, onRightClick: handleRightClick,
@ -128,7 +136,7 @@
const propsData = omit(item, 'title'); const propsData = omit(item, 'title');
const icon = getIcon({ ...item, level }, item.icon); const icon = getIcon({ ...item, level }, item.icon);
return ( return (
<Tree.TreeNode {...propsData} key={get(item, keyField)}> <Tree.TreeNode {...propsData} node={toRaw(item)} key={get(item, keyField)}>
{{ {{
title: () => ( title: () => (
<span class={`${prefixCls}-title`}> <span class={`${prefixCls}-title`}>