Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]form中reset不能够还原componentProps中的defaultValue #3814

Closed
4 tasks done
electroluxcode opened this issue May 8, 2024 · 0 comments · Fixed by #3815
Closed
4 tasks done

[BUG]form中reset不能够还原componentProps中的defaultValue #3814

electroluxcode opened this issue May 8, 2024 · 0 comments · Fixed by #3815

Comments

@electroluxcode
Copy link

electroluxcode commented May 8, 2024

⚠️ 重要 ⚠️ 在进一步操作之前,请检查下列选项。如果您忽视此模板或者没有提供关键信息,您的 Issue 将直接被关闭

  • 已阅读 文档.
  • 确保您的代码已是最新或者所报告的 Bug 在最新版本中可以重现. (部分 Bug 可能已经在最近的代码中修复)
  • 已在 Issues 中搜索了相关的关键词
  • 不是 ant design vue 组件库的 Bug

描述 Bug

点击页面重置 按钮的时候,应该重置成componentProps的defaultValue。
目前在进行了值的修改后点击重置 后却变成空值

复现 Bug

<template>
  <Alert message="bug" />
  <BasicForm @register="registerCustom" class="my-5" />
  <Button  @click="reset">点我还原默认值</Button>

</template>

<script setup lang="ts">
  import { Alert,Button } from 'ant-design-vue';
  import { BasicForm, FormSchema, useForm } from '@/components/Form';
  const schemasCustom: FormSchema[] = [
    {
      field: 'field1',
      component: 'ApiSelect',
      label: '字段1',
      componentProps: {
        defaultValue:"杰克",
        api: () => {
          return new Promise((resolve) => {
            resolve([
              {
                label: '111杰克',
                value: '杰克',
              },
              {
                label: '222伊莱克斯',
                value: '伊莱克斯',
              },
            ]);
          });
        },
      },
    },
    {
      field: 'field2',
      component: 'Input',
      label: '字段2',
      required:true,
      componentProps: {
        defaultValue:"默认input"
      },
    },
  ];
  const [registerCustom,{resetFields}] = useForm({
    labelWidth: 160,
    schemas: schemasCustom,
  });
  const reset = ()=>{
    resetFields()
  }
  
</script>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant