mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-05-29 11:36:37 +08:00
feat(design): drawer增加handleClose方法
This commit is contained in:
parent
75b0d9cdf3
commit
a9c5004f4d
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<component
|
<component
|
||||||
class="tmagic-design-drawer"
|
class="tmagic-design-drawer"
|
||||||
|
ref="drawer"
|
||||||
:is="uiComponent"
|
:is="uiComponent"
|
||||||
v-bind="uiProps"
|
v-bind="uiProps"
|
||||||
@open="openHandler"
|
@open="openHandler"
|
||||||
@ -22,7 +23,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
import { getConfig } from './config';
|
import { getConfig } from './config';
|
||||||
import type { DrawerProps } from './types';
|
import type { DrawerProps } from './types';
|
||||||
@ -41,6 +42,8 @@ const uiComponent = ui?.component || 'el-drawer';
|
|||||||
|
|
||||||
const uiProps = computed(() => ui?.props(props) || props);
|
const uiProps = computed(() => ui?.props(props) || props);
|
||||||
|
|
||||||
|
const drawer = ref<any>();
|
||||||
|
|
||||||
const openHandler = (...args: any[]) => {
|
const openHandler = (...args: any[]) => {
|
||||||
emit('open', ...args);
|
emit('open', ...args);
|
||||||
};
|
};
|
||||||
@ -56,4 +59,13 @@ const closedHandler = (...args: any[]) => {
|
|||||||
const updateModelValue = (v: any) => {
|
const updateModelValue = (v: any) => {
|
||||||
emit('update:modelValue', v);
|
emit('update:modelValue', v);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
handleClose: () => {
|
||||||
|
if (typeof drawer.value?.handleClose === 'function') {
|
||||||
|
return drawer.value.handleClose();
|
||||||
|
}
|
||||||
|
updateModelValue(false);
|
||||||
|
},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -481,7 +481,15 @@ export interface Components {
|
|||||||
};
|
};
|
||||||
|
|
||||||
drawer: {
|
drawer: {
|
||||||
component: DefineComponent<DrawerProps, {}, any> | string;
|
component:
|
||||||
|
| DefineComponent<
|
||||||
|
DrawerProps,
|
||||||
|
{
|
||||||
|
handleClose: () => void;
|
||||||
|
},
|
||||||
|
any
|
||||||
|
>
|
||||||
|
| string;
|
||||||
props: (props: DrawerProps) => DrawerProps;
|
props: (props: DrawerProps) => DrawerProps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user