处理表单状态,校验,简单自由的组合方式
非受控表单,单项数据流
form对象,可以操作单个Item状态
import FxForm , { FormItem } from 'fx-form'
<FxForm>
<FormItem name="xx" label="userName" rules="require">
<input/>
</FormItem>
<button type="submit"> 提交 </button>
</FxForm>
yarn add free-from
yarn run test
name | type | desc | default |
---|---|---|---|
init | function | 用于传递内部form操作对象的初始化方法 (form) => any |
undefind |
initValues | objeact | 初始化item值对象 | {} |
className | string | classname | "" |
formItemClassName | string | itemclassname | "" |
name | type | desc | default | require |
---|---|---|---|---|
name | string | 提交参数 | undefind | yes |
label | string / React.ReactElement | 默认显示字段 | undefind | no |
labelWidth | number | label宽度 | 150 | no |
rules | string / string[] / Rule / Rule[] | 错误处理, Rule类型为 reg, errorCss, errorMsg | "" | no |
className | string | itemclassname会覆盖FxForm传递的formItemClassName | "" | no |
name | type | desc |
---|---|---|
onSubmit | () => [ error, values ] | 提交表单,返回校验信息和value值 |
setItems | (name: string, value: any) => void | 设置item value |
onRest | () => void | 置空表单 |
values | objeact | 当前表单值 |
|
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project is licensed under the MIT License - see the LICENSE.md file for details
- girl friend give strong backing