Browse Source
fix: when the form is opened repeatedly, the state is unexpectedly destroyed (#4406)
pull/4402/head
Vben
5 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
8 additions and
1 deletions
-
packages/@core/ui-kit/form-ui/src/form-api.ts
-
playground/src/views/examples/modal/form-model-demo.vue
|
|
@ -177,7 +177,7 @@ export class FormApi { |
|
|
|
} |
|
|
|
|
|
|
|
unmounted() { |
|
|
|
this.state = null; |
|
|
|
// this.state = null;
|
|
|
|
this.isMounted = false; |
|
|
|
this.stateHandler.reset(); |
|
|
|
} |
|
|
|
|
|
@ -1,13 +1,20 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
import { useVbenModal } from '@vben/common-ui'; |
|
|
|
|
|
|
|
import { message } from 'ant-design-vue'; |
|
|
|
|
|
|
|
import { useVbenForm } from '#/adapter'; |
|
|
|
|
|
|
|
defineOptions({ |
|
|
|
name: 'FormModelDemo', |
|
|
|
}); |
|
|
|
|
|
|
|
function onSubmit(values: Record<string, any>) { |
|
|
|
message.info(JSON.stringify(values)); // 只会执行一次 |
|
|
|
} |
|
|
|
|
|
|
|
const [Form, formApi] = useVbenForm({ |
|
|
|
handleSubmit: onSubmit, |
|
|
|
schema: [ |
|
|
|
{ |
|
|
|
component: 'Input', |
|
|
|