mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-24 23:49:14 +08:00
perf: resolve beforeClose repeat trigger (#9283)
This commit is contained in:
parent
b41ed5a130
commit
c934710906
@ -1,4 +1,4 @@
|
||||
import { PropType, reactive, defineComponent } from 'vue';
|
||||
import { ref, PropType, reactive, defineComponent } from 'vue';
|
||||
|
||||
// Utils
|
||||
import {
|
||||
@ -68,10 +68,17 @@ export default defineComponent({
|
||||
cancel: false,
|
||||
});
|
||||
|
||||
const popupRef = ref();
|
||||
|
||||
const updateShow = (value: boolean) => emit('update:show', value);
|
||||
|
||||
const close = (action: DialogAction) => {
|
||||
updateShow(false);
|
||||
if (popupRef.value) {
|
||||
popupRef.value.triggerClose();
|
||||
} else {
|
||||
updateShow(false);
|
||||
}
|
||||
|
||||
if (props.callback) {
|
||||
props.callback(action);
|
||||
}
|
||||
@ -221,6 +228,7 @@ export default defineComponent({
|
||||
const { width, title, theme, message, className } = props;
|
||||
return (
|
||||
<Popup
|
||||
ref={popupRef}
|
||||
role="dialog"
|
||||
class={[bem([theme]), className]}
|
||||
style={{ width: addUnit(width) }}
|
||||
|
@ -229,7 +229,7 @@ export default defineComponent({
|
||||
}
|
||||
);
|
||||
|
||||
useExpose({ popupRef });
|
||||
useExpose({ popupRef, triggerClose });
|
||||
|
||||
useLockScroll(popupRef, () => props.show && props.lockScroll);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user