Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

daform

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

daform

daform 是一个高效开发表单的 one for all 方案。

latest
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

daform 是一个高效开发表单的 one for all 方案。

Philosophy

  • 双向绑定
  • 栅格化布局
  • 错误逻辑集中化管理
  • 动态表单的解决方案
  • 不依赖第三方状态管理库
  • 可自由搭配第三方 UI 组件库

issue

文档开发中...

Install

npm install daform

确保 React 版本为 ^16.6.3, 关于 React 16 特性可参考 React 特性剪辑(版本 16.0 ~ 16.9)

Basic Usage

import React from 'react'
import { Input } from 'antd'
import { Form, FormItem } from 'daForm'

@Form()
class Demo1 extends React.Component {
  render() {
    return (
      <>
        <FormItem name="name" label="姓名"><Input /></FormItem>
        <FormItem name="age" label="年龄"><Input /></FormItem>
      </>
    )
  }
}

Dynamic Form

daForm 内置了动态表单组件 <Dynamic>, 使用其可以快速完成增删配置需求。

import React from 'react'
import { Input } from 'antd'
import { Form, FormItem } from 'daForm'

@Form()
class Demo1 extends React.Component {
  render() {
    return (
      <Dynamic>
        <FormItem name="name" label="姓名"><Input /></FormItem>
        <FormItem name="age" label="年龄"><Input /></FormItem>
      </Dynamic>
    )
  }
}

API

Form

经过 Form 装饰的组件后具有 formerrorFields 对象。

  • form 提供的 api 见如下表格:
属性/方法意义
formData当前所有表单字段的数据映射
getFormItem(itemName)获取某一个表单字段的值
  • errorFields 包含当前表单的报错消息, 其等同于 async-validator 中的 fields 属性。

FormItem

FormItem 接受的属性见如下表格:

属性意义必填默认
name表单传输的名字yes
label表单的名字no''
colon是否带分号notrue
inline是否内联nofalse
labelCol表单的名字占位no8
wrapCol表单占位no16
disable是否禁用nofalse
initialValue初始(默认)值no

Dynamic

Dynamic 接受的属性见如下表格:

属性意义必填默认
initialValue动态表单的初始值(数组)no

Test

npm test

FAQs

Package last updated on 19 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts