@@ -28,11 +28,17 @@ import { ModalsContainer } from 'vue-final-modal'
2828``` ts
2929import { VueFinalModal , useModal } from ' vue-final-modal'
3030
31- const { open, close, options, patchOptions } = useModal ({
32- // `component` is optional and the default value is `<VueFinalModal>`.
33- component: VueFinalModal ,
31+ const { open, close, destroy, options, patchOptions } = useModal ({
3432 // Open the modal or not when the modal was created, the default value is `false`.
3533 defaultModelValue: false ,
34+ /**
35+ * If set `keepAlive` to `true`:
36+ * 1. The `displayDirective` will be set to `show` by default.
37+ * 2. The modal component will not be removed after the modal closed until you manually execute `destroy()`.
38+ */
39+ keepAlive: false ,
40+ // `component` is optional and the default value is `<VueFinalModal>`.
41+ component: VueFinalModal ,
3642 attrs: {
3743 // Bind props to the modal component (VueFinalModal in this case).
3844 clickToClose: true ,
@@ -49,6 +55,8 @@ const { open, close, options, patchOptions } = useModal({
4955open ().then (() => { /* Do something after modal opened */ })
5056// Close the modal
5157close ().then (() => { /* Do something after modal closed */ })
58+ // Destroy the modal manually, it only be needed when the `keepAlive` is set to `true`
59+ destroy ()
5260// Checkout the modal options
5361options // the state of the dynamic modal
5462
0 commit comments