feat(Dialog): add destroyOnClose prop to control content destruction on close (#13382)

This commit is contained in:
inottn
2025-03-08 20:13:46 +08:00
committed by GitHub
parent bfaceafc43
commit 1e390af577
4 changed files with 7 additions and 0 deletions

View File

@@ -63,6 +63,7 @@ export const dialogProps = extend({}, popupSharedProps, {
showConfirmButton: truthProp,
closeOnClickOverlay: Boolean,
keyboardEnabled: truthProp,
destroyOnClose: Boolean,
});
export type DialogProps = ExtractPropTypes<typeof dialogProps>;
@@ -71,6 +72,7 @@ const popupInheritKeys = [
...popupSharedPropKeys,
'transition',
'closeOnPopstate',
'destroyOnClose',
] as const;
export default defineComponent({

View File

@@ -172,6 +172,7 @@ Vant exports following Dialog utility functions:
| confirmButtonText | Confirm button text | _string_ | `Confirm` |
| confirmButtonColor | Confirm button color | _string_ | `#ee0a24` |
| confirmButtonDisabled | Whether to disable confirm button | _boolean_ | `false` |
| destroyOnClose `v4.9.18` | Whether to destroy content when closed | _boolean_ | `false` |
| overlay | Whether to show overlay | _boolean_ | `true` |
| overlayClass | Custom overlay class | _string \| Array \| object_ | - |
| overlayStyle | Custom overlay style | _object_ | - |
@@ -202,6 +203,7 @@ Vant exports following Dialog utility functions:
| confirm-button-text | Confirm button text | _string_ | `Confirm` |
| confirm-button-color | Confirm button color | _string_ | `#ee0a24` |
| confirm-button-disabled | Whether to disable confirm button | _boolean_ | `false` |
| destroy-on-close `v4.9.18` | Whether to destroy content when closed | _boolean_ | `false` |
| z-index | Set the z-index to a fixed value | _number \| string_ | `2000+` |
| overlay | Whether to show overlay | _boolean_ | `true` |
| overlay-class | Custom overlay class | _string_ | - |

View File

@@ -172,6 +172,7 @@ Vant 中导出了以下 Dialog 相关的辅助函数:
| cancelButtonText | 取消按钮文案 | _string_ | `取消` |
| cancelButtonColor | 取消按钮颜色 | _string_ | `black` |
| cancelButtonDisabled | 是否禁用取消按钮 | _boolean_ | `false` |
| destroyOnClose `v4.9.18` | 是否在关闭时销毁内容 | _boolean_ | `false` |
| overlay | 是否展示遮罩层 | _boolean_ | `true` |
| overlayClass | 自定义遮罩层类名 | _string \| Array \| object_ | - |
| overlayStyle | 自定义遮罩层样式 | _object_ | - |
@@ -204,6 +205,7 @@ Vant 中导出了以下 Dialog 相关的辅助函数:
| cancel-button-text | 取消按钮文案 | _string_ | `取消` |
| cancel-button-color | 取消按钮颜色 | _string_ | `black` |
| cancel-button-disabled | 是否禁用取消按钮 | _boolean_ | `false` |
| destroy-on-close `v4.9.18` | 是否在关闭时销毁内容 | _boolean_ | `false` |
| z-index | 将弹窗的 z-index 层级设置为一个固定值 | _number \| string_ | `2000+` |
| overlay | 是否展示遮罩层 | _boolean_ | `true` |
| overlay-class | 自定义遮罩层类名 | _string_ | - |

View File

@@ -31,6 +31,7 @@ const DEFAULT_OPTIONS = {
showCancelButton: false,
closeOnPopstate: true,
closeOnClickOverlay: false,
destroyOnClose: false,
} as const;
let currentOptions = extend({}, DEFAULT_OPTIONS);