Browse Source

fix: when the form is opened repeatedly, the state is unexpectedly destroyed (#4406)

pull/4402/head
Vben 1 year ago
committed by GitHub
parent
commit
02c4014ae3
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      packages/@core/ui-kit/form-ui/src/form-api.ts
  2. 7
      playground/src/views/examples/modal/form-model-demo.vue

2
packages/@core/ui-kit/form-ui/src/form-api.ts

@ -177,7 +177,7 @@ export class FormApi {
} }
unmounted() { unmounted() {
this.state = null; // this.state = null;
this.isMounted = false; this.isMounted = false;
this.stateHandler.reset(); this.stateHandler.reset();
} }

7
playground/src/views/examples/modal/form-model-demo.vue

@ -1,13 +1,20 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { message } from 'ant-design-vue';
import { useVbenForm } from '#/adapter'; import { useVbenForm } from '#/adapter';
defineOptions({ defineOptions({
name: 'FormModelDemo', name: 'FormModelDemo',
}); });
function onSubmit(values: Record<string, any>) {
message.info(JSON.stringify(values)); //
}
const [Form, formApi] = useVbenForm({ const [Form, formApi] = useVbenForm({
handleSubmit: onSubmit,
schema: [ schema: [
{ {
component: 'Input', component: 'Input',

Loading…
Cancel
Save