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