fix(modal): add v-model support for visible
This commit is contained in:
parent
b387681c00
commit
de12babd31
|
|
@ -81,7 +81,7 @@
|
|||
components: { Modal, ModalWrapper, ModalClose, ModalFooter, ModalHeader },
|
||||
inheritAttrs: false,
|
||||
props: basicProps,
|
||||
emits: ['visible-change', 'height-change', 'cancel', 'ok', 'register'],
|
||||
emits: ['visible-change', 'height-change', 'cancel', 'ok', 'register', 'update:visible'],
|
||||
setup(props, { emit, attrs }) {
|
||||
const visibleRef = ref(false);
|
||||
const propsRef = ref<Partial<ModalProps> | null>(null);
|
||||
|
|
@ -157,6 +157,7 @@
|
|||
() => unref(visibleRef),
|
||||
(v) => {
|
||||
emit('visible-change', v);
|
||||
emit('update:visible', v);
|
||||
instance && modalMethods.emitVisible?.(v, instance.uid);
|
||||
nextTick(() => {
|
||||
if (props.scrollTop && v && unref(modalWrapperRef)) {
|
||||
|
|
@ -180,7 +181,7 @@
|
|||
}
|
||||
|
||||
visibleRef.value = false;
|
||||
emit('cancel');
|
||||
emit('cancel', e);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -193,8 +194,8 @@
|
|||
visibleRef.value = !!props.visible;
|
||||
}
|
||||
|
||||
function handleOk() {
|
||||
emit('ok');
|
||||
function handleOk(e: Event) {
|
||||
emit('ok', e);
|
||||
}
|
||||
|
||||
function handleHeightChange(height: string) {
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@
|
|||
];
|
||||
});
|
||||
|
||||
function handleCancel() {
|
||||
emit('cancel');
|
||||
function handleCancel(e: Event) {
|
||||
emit('cancel', e);
|
||||
}
|
||||
function handleFullScreen(e: Event) {
|
||||
e?.stopPropagation();
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@
|
|||
props: basicProps,
|
||||
emits: ['ok', 'cancel'],
|
||||
setup(_, { emit }) {
|
||||
function handleOk() {
|
||||
emit('ok');
|
||||
function handleOk(e: Event) {
|
||||
emit('ok', e);
|
||||
}
|
||||
|
||||
function handleCancel() {
|
||||
emit('cancel');
|
||||
function handleCancel(e: Event) {
|
||||
emit('cancel', e);
|
||||
}
|
||||
return { handleOk, handleCancel };
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue