[BUG]form中reset不能够还原componentProps中的defaultValue
Closed this issue · 0 comments
electroluxcode commented
- 已阅读 文档.
- 确保您的代码已是最新或者所报告的 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>