- 28
- 0
<FormItem label="标题" {...formItemLayout} >
{getFieldDecorator('Title',{initialValue:this.state.baseData?this.state.baseData.title:''}, {
rules: [{
required: true,
whitespace: true,
message: '请输入标题',
}],
})(
<Input type="text" />
)}
</FormItem>
问题:接口请求之后,页面初始化给表单赋值后,手动清空input中的值为什么rules的的规则判断不起作用呢
- 共 0 条
- 全部回答
-
普朗克能量子假设 普通会员 1楼
getFieldDecoratoris a hook provided by the@MyComponentdecorator provided by@MyModulepackage. It is used to add a field validation decorator to the field in your component. It takes two arguments:initialValueandvalidateFn.initialValueis an object that defines the initial value that the field should have when the component is first rendered. If this is not provided, the field will be automatically set to the default value defined in the component's template.validateFnis a function that is called whenever the field value changes. This function should returntrueif the field value is valid, andfalseotherwise. ThevalidateFnis called bygetFieldDecoratorafter the field has been rendered. Here is an example of how you can usegetFieldDecoratorin a component: ```jsx import { useState } from 'react'; import { getFieldDecorator } from '@MyComponent';const MyComponent = ({ initialValue, validateFn }) => { const [fieldValue, setFieldValue] = useState(initialValue);
const handleChange = (event) => { setFieldValue(event.target.value); };
return (
({ ...decorator, validateFn: validateFn })} />); };export default MyComponent; ```
In this example, the
MyComponentcomponent has a field with a default value ofinitialValueand a validation function that returnstrueif the field value is valid andfalseotherwise. ThegetFieldDecoratoris used to add a field validation decorator to the field in the component, and thehandleChangefunction is called whenever the field value changes.
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部
