Gathering detailed insights and metrics for ant-design-mobile-form
Gathering detailed insights and metrics for ant-design-mobile-form
Gathering detailed insights and metrics for ant-design-mobile-form
Gathering detailed insights and metrics for ant-design-mobile-form
form-render-mobile
通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成
@canard/schema-form-antd-mobile-plugin
Ant Design Mobile components plugin for @canard/schema-form providing mobile-optimized form inputs for React Native and mobile web
@schema-plugin-flow/sifo-mplg-form-antd-mobile
sifo Form with ant-design-mobile.
@bmstravel/form-antd-mobile
A react component for rendering web forms in mobile browser from JSON schema using ant design mobile components
npm install ant-design-mobile-form
Typescript
Module System
Node Version
NPM Version
JavaScript (85.11%)
HTML (12.91%)
CSS (1.97%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
8 Stars
11 Commits
2 Forks
1 Watchers
27 Branches
1 Contributors
Updated on Jun 02, 2021
Latest Version
1.0.3
Package Id
ant-design-mobile-form@1.0.3
Unpacked Size
74.44 kB
Size
18.37 kB
File Count
8
NPM Version
5.6.0
Node Version
8.11.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
点击查看github,欢迎提issue~
表单怎么做校验才优雅呢?
在 PC 端,一个做的比较知名的方案是 Ant Design 的表单组件。它可以通过简单的 rule 配置,来实现“必填”,“自定义错误提示”,甚至自定义规则校验。 Ant Design 官网:https://3x.ant.design/components/form-cn/
然而在移动端,似乎从没一个组件库,做过类似的表单封装。哪怕 Ant Design Mobile,也没有做这个事情。
所以需要一个库,来实现这个功能。因 Ant Design Mobile 的用户基数较大,本库是基于 Ant Design Mobile 的一个“扩展”。
点击查看示例
1import React from "react"; 2import { List, Toast, Button, InputItem as _InputItem } from "antd-mobile"; 3import { create, addErrorExplanation } from "ant-design-mobile-form"; 4import "./App.css"; 5 6const InputItem = addErrorExplanation(_InputItem); 7 8const checkPhone = (rule, value, callback) => { 9 // check code 10}; 11 12class App extends React.Component { 13 handleSubmit = () => { 14 this.props.form.validateFields(async (errors, value) => { 15 if (errors === null) { 16 Toast.success(JSON.stringify(value)); 17 } 18 }); 19 }; 20 21 render = () => { 22 const { getFieldDecorator } = this.props.form; 23 24 return ( 25 <div className="container"> 26 <List> 27 {getFieldDecorator("phone", { 28 rules: [ 29 { 30 required: true, 31 message: "请输入您的手机号" 32 }, 33 { 34 validator: checkPhone 35 } 36 ] 37 })(<InputItem placeholder="手机号" />)} 38 39 {getFieldDecorator("password", { 40 rules: [ 41 { 42 required: true, 43 message: "请输入密码" 44 } 45 ] 46 })(<InputItem placeholder="密码" type="password" />)} 47 </List> 48 49 <Button 50 style={{ marginTop: 24 }} 51 onClick={this.handleSubmit} 52 type="primary" 53 > 54 登录 55 </Button> 56 </div> 57 ); 58 }; 59} 60 61export default create()(App);
对 Ant Design Mobile 原生的组件,如 InputItem
,Picker
等组件,需要用 addErrorExplanation
包裹,返回一个新的组件。该新组件支持错误提示,将在 getFieldDecorator
中使用:const MyInputItem = addErrorExplanation(InputItem)
。
在 Ant Design Mobile 里面,没有 Form
组件,所以这边的 FormComponent
更像是一个概念,一种代码层次上的 Form
,用法:export default create()(App)
该API用来对组件是至关重要的,跟Ant Design的 getFieldDecorator
用法基本类似,用来对表单项加校验规则。具体用法请参考上面的“基本用法”。
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 0/11 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
license file not detected
Details
Reason
no SAST tool detected
Details
Reason
project is not fuzzed
Details
Reason
110 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More