UNPKG

450 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3
4<head>
5 <meta charset="UTF-8">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <meta http-equiv="X-UA-Compatible" content="ie=edge">
8 <title>飞冰 DEMO 预览</title>
9 <style>
10 /*! normalize.css v3.0.2 | MIT License | git.io/normalize */
11
12 *,
13 *:before,
14 *:after {
15 box-sizing: border-box;
16 }
17
18 /**
19 * 1. Set default font family to sans-serif.
20 * 2. Prevent iOS text size adjust after orientation change, without disabling
21 * user zoom.
22 */
23
24 html {
25 font-family: sans-serif; /* 1 */
26 -ms-text-size-adjust: 100%; /* 2 */
27 -webkit-text-size-adjust: 100%; /* 2 */
28 }
29
30 /**
31 * Remove default margin.
32 */
33
34 body {
35 margin: 0;
36 }
37
38 /* HTML5 display definitions
39 ========================================================================== */
40
41 /**
42 * Correct `block` display not defined for any HTML5 element in IE 8/9.
43 * Correct `block` display not defined for `details` or `summary` in IE 10/11
44 * and Firefox.
45 * Correct `block` display not defined for `main` in IE 11.
46 */
47
48 article,
49 aside,
50 details,
51 figcaption,
52 figure,
53 footer,
54 header,
55 hgroup,
56 main,
57 menu,
58 nav,
59 section,
60 summary {
61 display: block;
62 }
63
64 /**
65 * 1. Correct `inline-block` display not defined in IE 8/9.
66 * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
67 */
68
69 audio,
70 canvas,
71 progress,
72 video {
73 display: inline-block; /* 1 */
74 vertical-align: baseline; /* 2 */
75 }
76
77 /**
78 * Prevent modern browsers from displaying `audio` without controls.
79 * Remove excess height in iOS 5 devices.
80 */
81
82 audio:not([controls]) {
83 display: none;
84 height: 0;
85 }
86
87 /**
88 * Address `[hidden]` styling not present in IE 8/9/10.
89 * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
90 */
91
92 [hidden],
93 template {
94 display: none;
95 }
96
97 /* Links
98 ========================================================================== */
99
100 /**
101 * Remove the gray background color from active links in IE 10.
102 */
103
104 a {
105 background-color: transparent;
106 }
107
108 /**
109 * Improve readability when focused and also mouse hovered in all browsers.
110 */
111
112 a:active,
113 a:hover {
114 outline: 0;
115 }
116
117 /* Text-level semantics
118 ========================================================================== */
119
120 /**
121 * Address styling not present in IE 8/9/10/11, Safari, and Chrome.
122 */
123
124 abbr[title] {
125 border-bottom: 1px dotted;
126 }
127
128 /**
129 * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
130 */
131
132 b,
133 strong {
134 font-weight: bold;
135 }
136
137 /**
138 * Address styling not present in Safari and Chrome.
139 */
140
141 dfn {
142 font-style: italic;
143 }
144
145 /**
146 * Address variable `h1` font-size and margin within `section` and `article`
147 * contexts in Firefox 4+, Safari, and Chrome.
148 */
149
150 h1 {
151 font-size: 2em;
152 margin: 0.67em 0;
153 }
154
155 /**
156 * Address styling not present in IE 8/9.
157 */
158
159 mark {
160 background: #ff0;
161 color: #000;
162 }
163
164 /**
165 * Address inconsistent and variable font size in all browsers.
166 */
167
168 small {
169 font-size: 80%;
170 }
171
172 /**
173 * Prevent `sub` and `sup` affecting `line-height` in all browsers.
174 */
175
176 sub,
177 sup {
178 font-size: 75%;
179 line-height: 0;
180 position: relative;
181 vertical-align: baseline;
182 }
183
184 sup {
185 top: -0.5em;
186 }
187
188 sub {
189 bottom: -0.25em;
190 }
191
192 /* Embedded content
193 ========================================================================== */
194
195 /**
196 * Remove border when inside `a` element in IE 8/9/10.
197 */
198
199 img {
200 border: 0;
201 }
202
203 /**
204 * Correct overflow not hidden in IE 9/10/11.
205 */
206
207 svg:not(:root) {
208 overflow: hidden;
209 }
210
211 /* Grouping content
212 ========================================================================== */
213
214 /**
215 * Address margin not present in IE 8/9 and Safari.
216 */
217
218 figure {
219 margin: 1em 40px;
220 }
221
222 /**
223 * Address differences between Firefox and other browsers.
224 */
225
226 hr {
227 -moz-box-sizing: content-box;
228 box-sizing: content-box;
229 height: 0;
230 }
231
232 /**
233 * Contain overflow in all browsers.
234 */
235
236 pre {
237 overflow: auto;
238 }
239
240 /**
241 * Address odd `em`-unit font size rendering in all browsers.
242 */
243
244 code,
245 kbd,
246 pre,
247 samp {
248 font-family: monospace, monospace;
249 font-size: 1em;
250 }
251
252 /* Forms
253 ========================================================================== */
254
255 /**
256 * Known limitation: by default, Chrome and Safari on OS X allow very limited
257 * styling of `select`, unless a `border` property is set.
258 */
259
260 /**
261 * 1. Correct color not being inherited.
262 * Known issue: affects color of disabled elements.
263 * 2. Correct font properties not being inherited.
264 * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
265 */
266
267 button,
268 input,
269 optgroup,
270 select,
271 textarea {
272 color: inherit; /* 1 */
273 font: inherit; /* 2 */
274 margin: 0; /* 3 */
275 }
276
277 /**
278 * Address `overflow` set to `hidden` in IE 8/9/10/11.
279 */
280
281 button {
282 overflow: visible;
283 }
284
285 /**
286 * Address inconsistent `text-transform` inheritance for `button` and `select`.
287 * All other form control elements do not inherit `text-transform` values.
288 * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
289 * Correct `select` style inheritance in Firefox.
290 */
291
292 button,
293 select {
294 text-transform: none;
295 }
296
297 /**
298 * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
299 * and `video` controls.
300 * 2. Correct inability to style clickable `input` types in iOS.
301 * 3. Improve usability and consistency of cursor style between image-type
302 * `input` and others.
303 */
304
305 /* 1 */ html input[type="button"],
306 button,
307 input[type="reset"],
308 input[type="submit"] {
309 -webkit-appearance: button; /* 2 */
310 cursor: pointer; /* 3 */
311 }
312
313 /**
314 * Re-set default cursor for disabled elements.
315 */
316
317 button[disabled],
318 html input[disabled] {
319 cursor: default;
320 }
321
322 /**
323 * Remove inner padding and border in Firefox 4+.
324 */
325
326 button::-moz-focus-inner,
327 input::-moz-focus-inner {
328 border: 0;
329 padding: 0;
330 }
331
332 /**
333 * Address Firefox 4+ setting `line-height` on `input` using `!important` in
334 * the UA stylesheet.
335 */
336
337 input {
338 line-height: normal;
339 }
340
341 /**
342 * It's recommended that you don't attempt to style these elements.
343 * Firefox's implementation doesn't respect box-sizing, padding, or width.
344 *
345 * 1. Address box sizing set to `content-box` in IE 8/9/10.
346 * 2. Remove excess padding in IE 8/9/10.
347 */
348
349 input[type="checkbox"],
350 input[type="radio"] {
351 box-sizing: border-box; /* 1 */
352 padding: 0; /* 2 */
353 }
354
355 /**
356 * Fix the cursor style for Chrome's increment/decrement buttons. For certain
357 * `font-size` values of the `input`, it causes the cursor style of the
358 * decrement button to change from `default` to `text`.
359 */
360
361 input[type="number"]::-webkit-inner-spin-button,
362 input[type="number"]::-webkit-outer-spin-button {
363 height: auto;
364 }
365
366 /**
367 * 1. Address `appearance` set to `searchfield` in Safari and Chrome.
368 * 2. Address `box-sizing` set to `border-box` in Safari and Chrome
369 * (include `-moz` to future-proof).
370 */
371
372 input[type="search"] {
373 -webkit-appearance: textfield; /* 1 */
374 -moz-box-sizing: content-box;
375 -webkit-box-sizing: content-box; /* 2 */
376 box-sizing: content-box;
377 }
378
379 /**
380 * Remove inner padding and search cancel button in Safari and Chrome on OS X.
381 * Safari (but not Chrome) clips the cancel button when the search input has
382 * padding (and `textfield` appearance).
383 */
384
385 input[type="search"]::-webkit-search-cancel-button,
386 input[type="search"]::-webkit-search-decoration {
387 -webkit-appearance: none;
388 }
389
390 /**
391 * Define consistent border, margin, and padding.
392 */
393
394 fieldset {
395 border: 1px solid #c0c0c0;
396 margin: 0 2px;
397 padding: 0.35em 0.625em 0.75em;
398 }
399
400 /**
401 * 1. Correct `color` not being inherited in IE 8/9/10/11.
402 * 2. Remove padding so people aren't caught out if they zero out fieldsets.
403 */
404
405 legend {
406 border: 0; /* 1 */
407 padding: 0; /* 2 */
408 }
409
410 /**
411 * Remove default vertical scrollbar in IE 8/9/10/11.
412 */
413
414 textarea {
415 overflow: auto;
416 }
417
418 /**
419 * Don't inherit the `font-weight` (applied by a rule above).
420 * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
421 */
422
423 optgroup {
424 font-weight: bold;
425 }
426
427 /* Tables
428 ========================================================================== */
429
430 /**
431 * Remove most spacing between table cells.
432 */
433
434 table {
435 border-collapse: collapse;
436 border-spacing: 0;
437 }
438
439 td,
440 th {
441 padding: 0;
442 }
443
444 code[class*="language-"],pre[class*="language-"]{color:black;background:none;text-shadow:0 1px white;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*="language-"]::-moz-selection,pre[class*="language-"] ::-moz-selection,code[class*="language-"]::-moz-selection,code[class*="language-"] ::-moz-selection{text-shadow:none;background:#b3d4fc}pre[class*="language-"]::selection,pre[class*="language-"] ::selection,code[class*="language-"]::selection,code[class*="language-"] ::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*="language-"],pre[class*="language-"]{text-shadow:none}}pre[class*="language-"]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*="language-"],pre[class*="language-"]{background:#f5f2f0}:not(pre)>code[class*="language-"]{padding:.1em;border-radius:.3em;white-space:normal}.token.comment,.token.prolog,.token.doctype,.token.cdata{color:slategray}.token.punctuation{color:#999}.namespace{opacity:.7}.token.property,.token.tag,.token.boolean,.token.number,.token.constant,.token.symbol,.token.deleted{color:#905}.token.selector,.token.attr-name,.token.string,.token.char,.token.builtin,.token.inserted{color:#690}.token.operator,.token.entity,.token.url,.language-css .token.string,.style .token.string{color:#a67f59;background:rgba(255,255,255,0.5)}.token.atrule,.token.attr-value,.token.keyword{color:#07a}.token.function{color:#DD4A68}.token.regex,.token.important,.token.variable{color:#e90}.token.important,.token.bold{font-weight:bold}.token.italic{font-style:italic}.token.entity{cursor:help}.markdown{color:#666;font-size:14px;line-height:1.8}.highlight{line-height:1.5}.markdown img{vertical-align:middle;max-width:100%}.markdown h1{color:#404040;font-weight:500;line-height:40px;margin-bottom:24px}.markdown h2,.markdown h3,.markdown h4,.markdown h5,.markdown h6{color:#404040;margin:1.6em 0 .6em 0;font-weight:500;clear:both}.markdown h1{font-size:28px}.markdown h2{font-size:22px}.markdown h3{font-size:18px}.markdown h4{font-size:16px}.markdown h5{font-size:14px}.markdown h6{font-size:12px}.markdown hr{height:1px;border:0;background:#e9e9e9;margin:16px 0;clear:both}.markdown p,.markdown pre{margin:1em 0}.markdown>p,.markdown>blockquote,.markdown>ol,.markdown>ul{width:80%}.markdown ul>li{list-style:circle}.markdown>ul li,.markdown blockquote ul>li{margin-left:20px;padding-left:4px}.markdown>ul li p,.markdown>ol li p{margin:.6em 0}.markdown ol>li{list-style:decimal}.markdown>ol li,.markdown blockquote ol>li{margin-left:20px;padding-left:4px}.markdown code{margin:0 3px}.markdown pre{border-radius:6px;background:#f7f7f7}.markdown pre code{border:none;padding:.5em;background:#f7f7f7;margin:0;display:block}.markdown strong,.markdown b{font-weight:600}.markdown>table{border-collapse:collapse;border-spacing:0;empty-cells:show;border:1px solid #e9e9e9;width:80%;margin-bottom:24px}.markdown>table th{white-space:nowrap;color:#5C6B77;font-weight:600}.markdown>table th,.markdown>table td{border:1px solid #e9e9e9;padding:8px 16px;text-align:left}.markdown>table th{background:#F7F7F7}.markdown>table td:first-child{background:#fcfcfc;font-weight:500;width:18%}.markdown>table td:nth-child(2){min-width:30%;max-width:45%}.markdown>table td:first-child{background:#fcfcfc}.markdown>table tr td:nth-last-child(-n+2){width:13%;word-break:break-all}.markdown blockquote{font-size:90%;color:#999;border-left:4px solid #e9e9e9;padding-left:.8em;margin:1em 0;font-style:italic}.markdown blockquote p{margin:0}.markdown .anchor{opacity:0;transition:opacity .3s ease;margin-left:8px}.markdown .waiting{color:#ccc}.markdown h1:hover .anchor,.markdown h2:hover .anchor,.markdown h3:hover .anchor,.markdown h4:hover .anchor,.markdown h5:hover .anchor,.markdown h6:hover .anchor{opacity:1;display:inline-block}.markdown>br,.markdown>p>br{clear:both}.container{margin:auto;box-sizing:border-box;padding-left:10%;padding-right:200px}.meta{border-bottom:2px solid #eee;line-height:24px;color:#666}.code-box{border:1px solid #E9E9E9;border-radius:6px;display:inline-block;width:100%;position:relative;margin:0 0 16px 0;transition:all .5s ease}.code-box:hover{border-color:#ccc}.code-box:target{border:1px solid rgba(45,183,245,0.7);box-shadow:0 0 4px rgba(45,183,245,0.5)}.code-box:hover .code-box-meta,.code-box:target .code-box-meta{background:#fbfbfb}.code-box:hover .code-box-title,.code-box:target .code-box-title{background:#fbfbfb;box-shadow:0 -1.2px 0 #e9e9e9}.code-box .code-box-title a,.code-box .code-box-title a:hover{color:#666}.code-box .code-box-demo{padding:42px 20px 50px}.code-box .highlight{overflow:hidden;padding:5px;border-top:1px dashed #e9e9e9}.code-box pre{margin:0;width:auto}
445
446 .demo-list{background-color:#fff;position:fixed;top:20px;right:10px;width:180px;border:1px solid #ddd;padding:0;border-radius:5px;list-style:none}.demo-list li{border-bottom:1px solid #ddd;border-left:3px solid #fff;padding:0 10px;line-height:26px;font-size:12px}.demo-list li.current{border-left:3px solid #f40}.demo-list li.current a{font-weight:700;color:#333}.demo-list li a{color:#36c;text-decoration:none}
447
448 .markdown code {
449 background: #f5f2f0;
450 margin: 0 3px;
451 padding: 2px 6px;
452 border-radius: 3px;
453 color: #dd4a68;
454 font-size: .8rem;
455 border: 1px solid #e9e9e9;
456 }
457 </style>
458<meta name="title" content="IceForm"><meta name="category" content="Components"><meta name="chinese" content="表单组件"><link href="./index.css" rel="stylesheet"></head>
459
460<body>
461 <div class="container">
462 <h1>
463 IceForm
464 表单组件
465 </h1>
466 <div class="markdown">
467 <p>表单组件</p>
468<h2>参数(Props)<a id="user-content-参数(props)" name="参数(props)" class="anchor" aria-hidden="true" href="#参数(props)"><span class="octicon octicon-link"></span></a></h2><table>
469<thead>
470<tr>
471<th>参数名</th>
472<th>说明</th>
473<th>必填</th>
474<th>类型</th>
475<th>默认值</th>
476<th>备注</th>
477</tr>
478</thead>
479<tbody><tr>
480<td>initialValues</td>
481<td>表单初始值</td>
482<td>N</td>
483<td>object</td>
484<td>{}</td>
485<td>-</td>
486</tr>
487<tr>
488<td>onSubmit</td>
489<td>submit函数</td>
490<td>Y</td>
491<td>function</td>
492<td>-</td>
493<td>-</td>
494</tr>
495<tr>
496<td>onChange</td>
497<td>表单变化回调</td>
498<td>N</td>
499<td>function</td>
500<td>-</td>
501<td>function(values: object, item: object) =&gt; void <br> 参数: <br> values: {object} 表单数据 <br> item: {object} 详细 <br> item.name: {string} 变化的组件名 <br> item.value: {string} 变化的数据</td>
502</tr>
503<tr>
504<td>rules</td>
505<td>校验规则</td>
506<td>N</td>
507<td>object</td>
508<td>{}</td>
509<td>-</td>
510</tr>
511<tr>
512<td>effects</td>
513<td>联动规则</td>
514<td>N</td>
515<td>array</td>
516<td>[]</td>
517<td>-</td>
518</tr>
519<tr>
520<td>layout</td>
521<td>表单布局</td>
522<td>N</td>
523<td>object</td>
524<td></td>
525<td>-</td>
526</tr>
527<tr>
528<td>renderField</td>
529<td>自定义 Field 布局</td>
530<td>N</td>
531<td>function</td>
532<td>-</td>
533<td>function({label, component, error}) =&gt; dom <br> 参数: <br> label: {string/element} Field 的 label <br> component: {string/function} 待渲染的控件 <br> error: {string/element} Field 错误提示信息</td>
534</tr>
535</tbody></table>
536<p>其他属性比如 <code>style</code><code>className</code> 等均会传递到 <code>form</code> 标签上。</p>
537<p><code>layout</code> 是个对象,包含 4 个属性:</p>
538
539 <div class="markdown">
540 <div class="highlight highlight-js">
541 <pre><code language="js"><span class="token punctuation">{</span>
542 labelAlign<span class="token punctuation">:</span> <span class="token string">'left'</span><span class="token punctuation">,</span> <span class="token comment">// label 的位置,'left'、'top',默认 'left'</span>
543 labelTextAlign<span class="token punctuation">:</span> <span class="token string">'right'</span><span class="token punctuation">,</span> <span class="token comment">// label 文字对齐方式,'left'、'right',默认 'right'</span>
544 labelCol<span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token comment">// label 占的栅格宽度,共 12 等分,默认 2</span>
545 wrapperCol<span class="token punctuation">:</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token comment">// 控件占的栅格宽度,共 12 等分,默认 6</span>
546<span class="token punctuation">}</span></code></pre>
547 </div>
548 </div>
549<p><code>rules</code> 是一个 Object,<code>key</code><code>&lt;Field&gt;</code><code>name</code> 属性值,<code>value</code> 是个数组,数组里面的每一项是一个校验规则,参考 <a href="https://github.com/yiminghe/async-validator" title="null">async-validator</a></p>
550
551 <div class="markdown">
552 <div class="highlight highlight-js">
553 <pre><code language="js"><span class="token operator">&lt;</span>Form
554 onSubmit<span class="token operator">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span>
555 style<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>color<span class="token punctuation">:</span> <span class="token string">'#ee7893'</span><span class="token punctuation">}</span><span class="token punctuation">}</span>
556 rules<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
557 username<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
558 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
559 min<span class="token punctuation">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
560 message<span class="token punctuation">:</span> <span class="token string">'姓名至少5个字符'</span>
561 <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
562 age<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
563 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
564 message<span class="token punctuation">:</span> <span class="token string">'年龄必填'</span>
565 <span class="token punctuation">}</span><span class="token punctuation">]</span>
566 <span class="token punctuation">}</span><span class="token punctuation">}</span>
567<span class="token operator">></span>
568 <span class="token operator">&lt;</span>Field label<span class="token operator">=</span><span class="token string">"姓名:"</span> name<span class="token operator">=</span><span class="token string">"username"</span> component<span class="token operator">=</span><span class="token string">"input"</span> type<span class="token operator">=</span><span class="token string">"text"</span> <span class="token operator">/</span><span class="token operator">></span>
569 <span class="token operator">&lt;</span>Field label<span class="token operator">=</span><span class="token string">"年龄:"</span> name<span class="token operator">=</span><span class="token string">"age"</span> component<span class="token operator">=</span><span class="token string">'input'</span> type<span class="token operator">=</span><span class="token string">"number"</span> <span class="token operator">/</span><span class="token operator">></span>
570<span class="token operator">&lt;</span><span class="token operator">/</span>Form<span class="token operator">></span></code></pre>
571 </div>
572 </div>
573<p><code>effects</code> 是个数组,写法如下:</p>
574
575 <div class="markdown">
576 <div class="highlight highlight-js">
577 <pre><code language="js"><span class="token operator">&lt;</span>Form
578 onSubmit<span class="token operator">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span>
579 effects<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span>
580 <span class="token punctuation">{</span>
581 field<span class="token punctuation">:</span> <span class="token string">'username'</span><span class="token punctuation">,</span>
582 <span class="token function-variable function">handler</span><span class="token punctuation">:</span> <span class="token parameter">formCore</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
583 <span class="token keyword">if</span> <span class="token punctuation">(</span>formCore<span class="token punctuation">.</span><span class="token function">getFieldValue</span><span class="token punctuation">(</span><span class="token string">'username'</span><span class="token punctuation">)</span> <span class="token operator">===</span> <span class="token string">'ice'</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
584 formCore<span class="token punctuation">.</span><span class="token function">setFieldValue</span><span class="token punctuation">(</span><span class="token string">'age'</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span>
585 <span class="token punctuation">}</span>
586 <span class="token punctuation">}</span>
587 <span class="token punctuation">}</span>
588 <span class="token punctuation">]</span><span class="token punctuation">}</span>
589<span class="token operator">></span>
590 <span class="token operator">&lt;</span>div<span class="token operator">></span>Hello Form<span class="token operator">&lt;</span><span class="token operator">/</span>div<span class="token operator">></span>
591 <span class="token operator">&lt;</span>Field label<span class="token operator">=</span><span class="token string">"姓名:"</span> name<span class="token operator">=</span><span class="token string">"username"</span> component<span class="token operator">=</span><span class="token string">"input"</span> type<span class="token operator">=</span><span class="token string">"text"</span> <span class="token operator">/</span><span class="token operator">></span>
592 <span class="token operator">&lt;</span>Field label<span class="token operator">=</span><span class="token string">"年龄:"</span> name<span class="token operator">=</span><span class="token string">"age"</span> component<span class="token operator">=</span><span class="token string">'input'</span> type<span class="token operator">=</span><span class="token string">"number"</span> <span class="token operator">/</span><span class="token operator">></span>
593 <span class="token operator">&lt;</span>button type<span class="token operator">=</span><span class="token string">"submit"</span><span class="token operator">></span>Submit<span class="token operator">&lt;</span><span class="token operator">/</span>button<span class="token operator">></span>
594<span class="token operator">&lt;</span><span class="token operator">/</span>Form<span class="token operator">></span></code></pre>
595 </div>
596 </div>
597<p>监听该 <code>field</code><code>onChange</code> 事件,然后设置其他表单项的数据,从而达到联动效果。<code>handler</code> 的参数是 <code>formCore</code> 对象,该对象暴露一些 api 可以设置 value、error、show/hide 等。</p>
598<h2>Field 组件<a id="user-content-field-组件" name="field-组件" class="anchor" aria-hidden="true" href="#field-组件"><span class="octicon octicon-link"></span></a></h2><table>
599<thead>
600<tr>
601<th>参数名</th>
602<th>说明</th>
603<th>必填</th>
604<th>类型</th>
605<th>默认值</th>
606<th>备注</th>
607</tr>
608</thead>
609<tbody><tr>
610<td>label</td>
611<td>表单项的 label</td>
612<td>N</td>
613<td>string/element</td>
614<td>-</td>
615<td>-</td>
616</tr>
617<tr>
618<td>name</td>
619<td>表单项的 name</td>
620<td>Y</td>
621<td>string</td>
622<td>-</td>
623<td>-</td>
624</tr>
625<tr>
626<td>component</td>
627<td>表单类型,原生 html 标签或者三方组件</td>
628<td>N</td>
629<td>string/function</td>
630<td>-</td>
631<td>&#39;input&#39; &#39;textarea&#39; Input Radio</td>
632</tr>
633<tr>
634<td>value</td>
635<td>表单项的值</td>
636<td>N</td>
637<td>-</td>
638<td>&#39;&#39;</td>
639<td>-</td>
640</tr>
641<tr>
642<td>rules</td>
643<td>校验规则</td>
644<td>N</td>
645<td>object or array</td>
646<td>-</td>
647<td>-</td>
648</tr>
649<tr>
650<td>effects</td>
651<td>联动规则</td>
652<td>N</td>
653<td>object</td>
654<td>-</td>
655<td>-</td>
656</tr>
657<tr>
658<td>visible</td>
659<td>显示隐藏当前 Field</td>
660<td>N</td>
661<td>boolean</td>
662<td>true</td>
663<td>true/false</td>
664</tr>
665<tr>
666<td>setValueFormatter</td>
667<td>格式化控件渲染值</td>
668<td>N</td>
669<td>function</td>
670<td></td>
671<td>function(savedValue) =&gt; renderValue</td>
672</tr>
673<tr>
674<td>getValueFormatter</td>
675<td>格式化控件提交值</td>
676<td>N</td>
677<td>function</td>
678<td></td>
679<td>function(renderValue) =&gt; savedValue</td>
680</tr>
681<tr>
682<td>layout</td>
683<td>设置当前 Field 的布局</td>
684<td>N</td>
685<td>object</td>
686<td>同 Form layout</td>
687<td>当前 Field 的 layout 会覆盖 Form 的 layout</td>
688</tr>
689<tr>
690<td>tips</td>
691<td>提示信息</td>
692<td>N</td>
693<td>string</td>
694<td></td>
695<td></td>
696</tr>
697<tr>
698<td>valueName</td>
699<td>控件值的名称,比如,radio 的 valueName 为 &#39;checked&#39;,value 为 true/false</td>
700<td>N</td>
701<td>string</td>
702<td></td>
703<td>比如 Fusion 的 Switch 组件</td>
704</tr>
705<tr>
706<td>errorRender</td>
707<td>自定义 error 渲染</td>
708<td>N</td>
709<td>function(error) {}</td>
710<td></td>
711<td></td>
712</tr>
713<tr>
714<td>onChange</td>
715<td>自定义 onChange 函数</td>
716<td>N</td>
717<td>function() {}</td>
718<td></td>
719<td>默认情况下已处理表单的 onChange(eventOrValue) 事件,如果接入的三方控件 onChange 的第一个参数不是 event 或者 value,可以主动设置对应的值。比如,接入控件的 onChange(xxx, value) 第二个参数才是 value,则可以手动设置 <code>formCore.setValue(fieldname, value)</code></td>
720</tr>
721</tbody></table>
722<p><code>style</code><code>className</code> 属性会传递到 Field 最外层 dom 上,其他属性会传递到 <code>component</code> 上,如果没有 <code>component</code> 但有 <code>children</code>,则属性传递到 <code>children</code> 上。</p>
723<p><code>Field</code><code>rules</code><code>effects</code> 不需要 <code>name</code> 作为 key 了,写法如下:</p>
724
725 <div class="markdown">
726 <div class="highlight highlight-js">
727 <pre><code language="js"><span class="token operator">&lt;</span>Form onSubmit<span class="token operator">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span><span class="token operator">></span>
728 <span class="token operator">&lt;</span>Field label<span class="token operator">=</span><span class="token string">"姓名:"</span> name<span class="token operator">=</span><span class="token string">"username"</span> component<span class="token operator">=</span><span class="token string">"input"</span> type<span class="token operator">=</span><span class="token string">"text"</span> <span class="token operator">/</span><span class="token operator">></span>
729 <span class="token operator">&lt;</span>Field label<span class="token operator">=</span><span class="token string">"昵称:"</span> name<span class="token operator">=</span><span class="token string">"nickname"</span> component<span class="token operator">=</span><span class="token string">"input"</span> type<span class="token operator">=</span><span class="token string">"text"</span> effects<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
730 <span class="token function-variable function">handler</span><span class="token punctuation">:</span> <span class="token parameter">formCore</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
731 <span class="token keyword">if</span> <span class="token punctuation">(</span>formCore<span class="token punctuation">.</span><span class="token function">getFieldValue</span><span class="token punctuation">(</span><span class="token string">'nickname'</span><span class="token punctuation">)</span> <span class="token operator">===</span> <span class="token string">'snow'</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
732 formCore<span class="token punctuation">.</span><span class="token function">setFieldProps</span><span class="token punctuation">(</span><span class="token string">'age'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
733 visible<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
734 <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
735 <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
736 formCore<span class="token punctuation">.</span><span class="token function">setFieldProps</span><span class="token punctuation">(</span><span class="token string">'age'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
737 visible<span class="token punctuation">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
738 <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
739 <span class="token punctuation">}</span>
740 <span class="token punctuation">}</span>
741 <span class="token punctuation">}</span><span class="token punctuation">}</span> <span class="token operator">/</span><span class="token operator">></span>
742 <span class="token operator">&lt;</span>Field label<span class="token operator">=</span><span class="token string">"年龄:"</span> name<span class="token operator">=</span><span class="token string">"age"</span> component<span class="token operator">=</span><span class="token string">'input'</span> type<span class="token operator">=</span><span class="token string">"number"</span> rules<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span><span class="token punctuation">{</span>
743 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
744 message<span class="token punctuation">:</span> <span class="token string">'年龄必填'</span>
745 <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">}</span> <span class="token operator">/</span><span class="token operator">></span>
746 <span class="token operator">&lt;</span>button type<span class="token operator">=</span><span class="token string">"submit"</span><span class="token operator">></span>Submit<span class="token operator">&lt;</span><span class="token operator">/</span>button<span class="token operator">></span>
747<span class="token operator">&lt;</span><span class="token operator">/</span>Form<span class="token operator">></span></code></pre>
748 </div>
749 </div>
750<h2>FieldArray 组件<a id="user-content-fieldarray-组件" name="fieldarray-组件" class="anchor" aria-hidden="true" href="#fieldarray-组件"><span class="octicon octicon-link"></span></a></h2><p>FieldArray 表示渲染数组类型的数据,属性同 Field:</p>
751
752 <div class="markdown">
753 <div class="highlight highlight-js">
754 <pre><code language="js"><span class="token operator">&lt;</span>Form
755 onSubmit<span class="token operator">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span>
756<span class="token operator">></span>
757 <span class="token operator">&lt;</span>FieldArray label<span class="token operator">=</span><span class="token string">"新增顾客:"</span> name<span class="token operator">=</span><span class="token string">"customers"</span><span class="token operator">></span>
758 <span class="token operator">&lt;</span>Field name<span class="token operator">=</span><span class="token string">"customer0"</span> component<span class="token operator">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span> placeholder<span class="token operator">=</span><span class="token string">"customer name"</span> <span class="token operator">/</span><span class="token operator">></span>
759 <span class="token operator">&lt;</span>Field name<span class="token operator">=</span><span class="token string">"customer1"</span> component<span class="token operator">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span> placeholder<span class="token operator">=</span><span class="token string">"customer name"</span> <span class="token operator">/</span><span class="token operator">></span>
760 <span class="token operator">&lt;</span>Field name<span class="token operator">=</span><span class="token string">"customer2"</span> component<span class="token operator">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span> placeholder<span class="token operator">=</span><span class="token string">"customer name"</span> <span class="token operator">/</span><span class="token operator">></span>
761 <span class="token operator">&lt;</span><span class="token operator">/</span>FieldArray<span class="token operator">></span>
762 <span class="token operator">&lt;</span>Field label<span class="token operator">=</span><span class="token string">"日期:"</span> name<span class="token operator">=</span><span class="token string">"date"</span> component<span class="token operator">=</span><span class="token punctuation">{</span>DatePicker<span class="token punctuation">}</span> <span class="token operator">/</span><span class="token operator">></span>
763 <span class="token operator">&lt;</span>Field label<span class="token operator">=</span><span class="token string">""</span><span class="token operator">></span>
764 <span class="token operator">&lt;</span>Button htmlType<span class="token operator">=</span><span class="token string">"submit"</span><span class="token operator">></span>Submit<span class="token operator">&lt;</span><span class="token operator">/</span>Button<span class="token operator">></span>
765 <span class="token operator">&lt;</span><span class="token operator">/</span>Field<span class="token operator">></span>
766<span class="token operator">&lt;</span><span class="token operator">/</span>Form<span class="token operator">></span></code></pre>
767 </div>
768 </div>
769<h2><code>formCore</code> API<a id="user-content-<code>formcore</code>-api" name="<code>formcore</code>-api" class="anchor" aria-hidden="true" href="#<code>formcore</code>-api"><span class="octicon octicon-link"></span></a></h2><p><code>formCore</code> 会暴露一些 API,使用这些 API 可以获取、设置表单的数据、状态等。</p>
770<ul>
771<li><code>getFieldValue(name)</code>:获取某一 <code>Field</code> 的值</li>
772<li><code>setFieldValue(name, value)</code>:设置某一 <code>Field</code> 的值</li>
773<li><code>getValues()</code>:获取表单的 values</li>
774<li><code>setValues(values, runEffects)</code>:设置表单的 values,runEffects 为 Boolean,表示设置 values 之后是否需要执行表单的 effects,默认 false</li>
775<li><code>getFieldError(name)</code>:获取某一 <code>Field</code> 的 error 信息</li>
776<li><code>setFieldError(name, errMsg)</code>:设置某一 <code>Field</code> 的 error 信息</li>
777<li><code>getErrors()</code>:获取所有 <code>Field</code> 的 error 信息</li>
778<li><code>setErrors(errors)</code>:设置某些 <code>Field</code> 的 error 信息</li>
779<li><code>getFieldProps(name)</code>:获取某一 <code>Field</code> 的属性值</li>
780<li><code>setFieldProps(name, prop)</code>:设置某一 <code>Field</code> 的属性值</li>
781<li><code>submit()</code>:提交表单</li>
782<li><code>reset(initialValues)</code>:重置表单值为表单初始化时的默认值,如果表单初始化时没有默认值,则清空表单;如果传了参数 initialValues,则 initialValues 会成为新的表单默认值</li>
783</ul>
784<p>也可以通过属性的方式获取到一些数据:</p>
785<ul>
786<li><code>formCore.values</code>:获取表单的所有值</li>
787<li><code>formCore.errors</code>:获取表单校验的错误信息</li>
788<li><code>formCore.pristine</code>:表单当前的 <code>values</code> 是否与 <code>initialValues</code> 相等</li>
789</ul>
790<h2>延伸阅读<a id="user-content-延伸阅读" name="延伸阅读" class="anchor" aria-hidden="true" href="#延伸阅读"><span class="octicon octicon-link"></span></a></h2><h3>开发 @ice/form 表单背景<a id="user-content-开发-@ice/form-表单背景" name="开发-@ice/form-表单背景" class="anchor" aria-hidden="true" href="#开发-@ice/form-表单背景"><span class="octicon octicon-link"></span></a></h3><p>对于前端,表单开发是一件特别繁琐的事情,尤其在中后台业务中,大家常常会被各种五花八门的表单折磨,又不得不面对现实地去寻找最佳方案,但最终都会发现过度设计的表单组件性能不好,使用简单的表单组件还是需要写大量的业务代码。经过长期的积累以及在社区的调研,我们开发了一个表单组件帮助大家快速地创建一个高性能表单。</p>
791<h3>组件特性<a id="user-content-组件特性" name="组件特性" class="anchor" aria-hidden="true" href="#组件特性"><span class="octicon octicon-link"></span></a></h3><ul>
792<li>内部几乎无依赖,体积小</li>
793<li>内部管理表单状态,提升开发效率</li>
794<li>使用观察者模式提升表单性能</li>
795<li>强大的校验以及声明式联动</li>
796<li>可结合第三方组件库(Next、Antd)</li>
797<li>可自定义 Field</li>
798</ul>
799<h3>架构方案<a id="user-content-架构方案" name="架构方案" class="anchor" aria-hidden="true" href="#架构方案"><span class="octicon octicon-link"></span></a></h3><p><img src="https://img.alicdn.com/tfs/TB1gFAvaUGF3KVjSZFoXXbmpFXa-1024-768.jpg" alt=""></p>
800<p>如上图所示,整个表单的数据都放在 FormCore 这一层,同时 FormCore 会暴露一些 API,以便获取、设置、处理数据。Form、Field 组件通过 Sub/Pub 模式与 FormCore 通信,FormCore 通知组件何时重新渲染。表单提供了校验、联动以及结合 Fusion、Antd 三方组件库使用等能力。</p>
801<h3>竞品对比<a id="user-content-竞品对比" name="竞品对比" class="anchor" aria-hidden="true" href="#竞品对比"><span class="octicon octicon-link"></span></a></h3><p><strong><a href="https://github.com/alibaba/nopage" title="null">NoForm</a></strong></p>
802<p>NoForm 是一个表单操作(比如说校验、提交、联动等)抽象到上层,下层又包装了 Next、Antd 等组件,UI 上的能力较强,也封装了一些常用的布局,但功能能力较弱,用户实现复杂逻辑还是需要写很多代码。</p>
803<p><strong><a href="https://github.com/jaredpalmer/formik" title="null">Formik</a></strong><strong><a href="https://github.com/final-form/react-final-form" title="null">react-final-form</a></strong></p>
804<p>这两个组件有一些共性,都是通过 render props 的方式实现了复杂的状态管理,在性能上也非常地卓越,在社区得到了大量的好评,但在联动上的能力较弱(目前只能更新 value),而且如果要集成 Next 或者 Antd 需要将库的表单组件都封装成 Field,成本较高。</p>
805<h3>相关链接<a id="user-content-相关链接" name="相关链接" class="anchor" aria-hidden="true" href="#相关链接"><span class="octicon octicon-link"></span></a></h3><ul>
806<li><a href="https://github.com/jaredpalmer/formik" title="null">formik</a></li>
807<li><a href="https://github.com/final-form/react-final-form" title="null">react-final-form</a></li>
808<li><a href="https://alibaba.github.io/nopage/#/nopage/noform/brief-intro" title="null">noform</a></li>
809</ul>
810
811 </div>
812 <h3>DEMO 列表</h3>
813 <div>
814 <div class="preview" id="container_simple">
815 <h3>基本用法</h3>
816 <div class="markdown">
817 <p><code>Form</code> 的基本用法</p>
818
819 </div>
820 <div class="code-box">
821 <div class="code-box-demo">
822 <div id="simple"></div>
823 </div>
824 <div class="markdown">
825 <div class="highlight">
826 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
827<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
828<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
829<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input<span class="token punctuation">,</span> Switch<span class="token punctuation">,</span> Select<span class="token punctuation">,</span> Checkbox <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
830
831<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
832
833<span class="token keyword">const</span> Option <span class="token operator">=</span> Select<span class="token punctuation">.</span>Option<span class="token punctuation">;</span>
834
835<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
836 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
837 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
838 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
839 <span class="token punctuation">}</span>
840
841 <span class="token function">onChange</span><span class="token punctuation">(</span><span class="token parameter">values<span class="token punctuation">,</span> field</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
842 console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> field<span class="token punctuation">)</span><span class="token punctuation">;</span>
843 <span class="token punctuation">}</span>
844
845 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
846 <span class="token keyword">return</span> <span class="token punctuation">(</span>
847 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
848 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
849 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
850 <span class="token attr-name">onChange</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onChange<span class="token punctuation">}</span></span>
851 <span class="token attr-name">initialValues</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
852 username<span class="token punctuation">:</span> <span class="token string">'icer'</span><span class="token punctuation">,</span>
853 age<span class="token punctuation">:</span> <span class="token number">3</span><span class="token punctuation">,</span>
854 intro<span class="token punctuation">:</span> <span class="token string">'让前端开发简单而友好'</span>
855 <span class="token punctuation">}</span><span class="token punctuation">}</span></span>
856 <span class="token punctuation">></span></span>
857 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>个人资料<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
858 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>姓名:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>username<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
859 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
860 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>简介:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">.</span>TextArea<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请简单介绍一下自己的工作经历<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
861 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>开关:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>open<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Switch<span class="token punctuation">}</span></span> <span class="token attr-name">valueName</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>checked<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
862 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>尺寸:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>size<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Select<span class="token punctuation">}</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>medium<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请选择尺寸<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
863 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>small<span class="token punctuation">"</span></span> <span class="token attr-name">key</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>small<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Option</span></span><span class="token punctuation">></span></span>
864 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>medium<span class="token punctuation">"</span></span> <span class="token attr-name">key</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>medium<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Option</span></span><span class="token punctuation">></span></span>
865 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>large<span class="token punctuation">"</span></span> <span class="token attr-name">key</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>large<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Option</span></span><span class="token punctuation">></span></span>
866 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
867 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>选项:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>checkbox<span class="token punctuation">"</span></span> <span class="token attr-name">value</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span><span class="token string">'b'</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Checkbox<span class="token punctuation">.</span>Group<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
868 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>a<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>选项一<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>
869 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>b<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>选项二<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>
870 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">disabled</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>c<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>选项三(disabled)<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>
871 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
872 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
873 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
874 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
875 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
876 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
877 <span class="token punctuation">)</span><span class="token punctuation">;</span>
878 <span class="token punctuation">}</span>
879<span class="token punctuation">}</span>
880
881ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
882 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
883<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
884 </div>
885 </div>
886 </div>
887 </div>
888 <div class="preview" id="container_reset">
889 <h3>重置表单</h3>
890 <div class="markdown">
891 <p><code>Form</code> 子组件使用 <code>function</code> 渲染时,可以调用 <code>FormCore</code> 中的 <code>API</code></p>
892
893 </div>
894 <div class="code-box">
895 <div class="code-box-demo">
896 <div id="reset"></div>
897 </div>
898 <div class="markdown">
899 <div class="highlight">
900 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
901<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
902<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
903<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
904
905<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
906
907<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
908 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
909 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
910 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
911 <span class="token punctuation">}</span>
912
913 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
914 <span class="token keyword">const</span> initialValues <span class="token operator">=</span> <span class="token punctuation">{</span>
915 username<span class="token punctuation">:</span> <span class="token string">'icer'</span><span class="token punctuation">,</span>
916 age<span class="token punctuation">:</span> <span class="token number">3</span><span class="token punctuation">,</span>
917 intro<span class="token punctuation">:</span> <span class="token string">'让前端开发简单而友好'</span>
918 <span class="token punctuation">}</span><span class="token punctuation">;</span>
919
920 <span class="token keyword">return</span> <span class="token punctuation">(</span>
921 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
922 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
923 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
924 <span class="token attr-name">initialValues</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>initialValues<span class="token punctuation">}</span></span>
925 <span class="token punctuation">></span></span>
926 <span class="token punctuation">{</span><span class="token parameter">formCore</span> <span class="token operator">=></span> <span class="token punctuation">(</span>
927 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
928 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>个人资料<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
929 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>姓名:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>username<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
930 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
931 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>简介:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">.</span>TextArea<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请简单介绍一下自己的工作经历<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
932 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
933 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
934 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>marginRight<span class="token punctuation">:</span> <span class="token string">'20px'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
935 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> formCore<span class="token punctuation">.</span><span class="token function">reset</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>Reset<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
936 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
937 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
938 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
939 <span class="token punctuation">)</span><span class="token punctuation">}</span>
940 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
941 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
942 <span class="token punctuation">)</span><span class="token punctuation">;</span>
943 <span class="token punctuation">}</span>
944<span class="token punctuation">}</span>
945
946ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
947 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
948<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
949 </div>
950 </div>
951 </div>
952 </div>
953 <div class="preview" id="container_validation">
954 <h3>基础校验</h3>
955 <div class="markdown">
956 <p>校验规则可以写在 <code>Form</code> 属性上或者 <code>Field</code> 属性上</p>
957
958 </div>
959 <div class="code-box">
960 <div class="code-box-demo">
961 <div id="validation"></div>
962 </div>
963 <div class="markdown">
964 <div class="highlight">
965 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
966<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
967<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
968<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
969
970<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
971
972<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
973 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
974 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
975 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
976 <span class="token punctuation">}</span>
977
978 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
979 <span class="token keyword">return</span> <span class="token punctuation">(</span>
980 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
981 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
982 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
983 <span class="token attr-name">rules</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
984 username<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
985 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
986 min<span class="token punctuation">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
987 message<span class="token punctuation">:</span> <span class="token string">'姓名至少5个字符'</span>
988 <span class="token punctuation">}</span><span class="token punctuation">]</span>
989 <span class="token punctuation">}</span><span class="token punctuation">}</span></span>
990 <span class="token punctuation">></span></span>
991 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>个人资料<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
992 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>姓名:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>username<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span>
993 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token attr-name">rules</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span><span class="token punctuation">{</span>
994 message<span class="token punctuation">:</span> <span class="token string">'年龄必填且大于18岁'</span><span class="token punctuation">,</span>
995 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
996 <span class="token function-variable function">validator</span><span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token parameter">rule<span class="token punctuation">,</span> value</span><span class="token punctuation">)</span> <span class="token operator">=></span> value <span class="token operator">></span> <span class="token number">18</span>
997 <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
998 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>简介:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">.</span>TextArea<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请简单介绍一下自己的工作经历<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
999 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1000 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1001 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1002 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1003 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1004 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1005 <span class="token punctuation">}</span>
1006<span class="token punctuation">}</span>
1007
1008ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1009 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1010<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1011 </div>
1012 </div>
1013 </div>
1014 </div>
1015 <div class="preview" id="container_async-validation">
1016 <h3>异步校验</h3>
1017 <div class="markdown">
1018 <p>异步校验,校验结果的 <code>message</code> 直接 <code>callback</code> 即可</p>
1019
1020 </div>
1021 <div class="code-box">
1022 <div class="code-box-demo">
1023 <div id="async-validation"></div>
1024 </div>
1025 <div class="markdown">
1026 <div class="highlight">
1027 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1028<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1029<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1030<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
1031
1032<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1033
1034<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1035 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1036 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1037 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1038 <span class="token punctuation">}</span>
1039
1040 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1041 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1042 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1043 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span> <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
1044 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>个人资料<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
1045 <span class="token operator">&lt;</span>Field name<span class="token operator">=</span><span class="token string">"name"</span> label<span class="token operator">=</span><span class="token string">"名称:"</span> component<span class="token operator">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span> autoComplete<span class="token operator">=</span><span class="token string">"off"</span> placeholder<span class="token operator">=</span><span class="token string">"请输入名字"</span> rules<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
1046 <span class="token keyword">async</span> <span class="token function">asyncValidator</span><span class="token punctuation">(</span><span class="token parameter">rule<span class="token punctuation">,</span> value<span class="token punctuation">,</span> callback</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1047 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
1048 <span class="token function">callback</span><span class="token punctuation">(</span><span class="token string">'名称必填'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1049 <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
1050 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">500</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1051
1052 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">~</span><span class="token punctuation">[</span><span class="token string">'john'</span><span class="token punctuation">,</span> <span class="token string">'paul'</span><span class="token punctuation">,</span> <span class="token string">'george'</span><span class="token punctuation">,</span> <span class="token string">'ringo'</span><span class="token punctuation">]</span><span class="token punctuation">.</span><span class="token function">indexOf</span><span class="token punctuation">(</span>value<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1053 <span class="token function">callback</span><span class="token punctuation">(</span><span class="token string">'名称已存在'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1054 <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
1055 <span class="token function">callback</span><span class="token punctuation">(</span><span class="token keyword">undefined</span><span class="token punctuation">)</span>
1056 <span class="token punctuation">}</span>
1057 <span class="token punctuation">}</span>
1058 <span class="token punctuation">}</span>
1059 <span class="token punctuation">}</span><span class="token punctuation">}</span> <span class="token operator">/</span><span class="token operator">></span>
1060 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token attr-name">rules</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span><span class="token punctuation">{</span>
1061 message<span class="token punctuation">:</span> <span class="token string">'年龄必填且大于18岁'</span><span class="token punctuation">,</span>
1062 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
1063 <span class="token function-variable function">validator</span><span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token parameter">rule<span class="token punctuation">,</span> value</span><span class="token punctuation">)</span> <span class="token operator">=></span> value <span class="token operator">></span> <span class="token number">18</span>
1064 <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
1065 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>简介:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">.</span>TextArea<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请简单介绍一下自己的工作经历<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1066 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1067 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1068 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1069 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1070 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1071 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1072 <span class="token punctuation">}</span>
1073<span class="token punctuation">}</span>
1074
1075ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1076 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1077<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1078 </div>
1079 </div>
1080 </div>
1081 </div>
1082 <div class="preview" id="container_linkage">
1083 <h3>基础联动</h3>
1084 <div class="markdown">
1085 <p>基础联动</p>
1086
1087 </div>
1088 <div class="code-box">
1089 <div class="code-box-demo">
1090 <div id="linkage"></div>
1091 </div>
1092 <div class="markdown">
1093 <div class="highlight">
1094 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1095<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1096<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1097<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input<span class="token punctuation">,</span> Radio <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
1098
1099<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1100
1101<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1102 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1103 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1104 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1105 <span class="token punctuation">}</span>
1106
1107 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1108 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1109 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1110 <span class="token operator">&lt;</span>Form
1111 onSubmit<span class="token operator">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span>
1112 rules<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
1113 username<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
1114 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
1115 min<span class="token punctuation">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
1116 message<span class="token punctuation">:</span> <span class="token string">'姓名至少5个字符'</span>
1117 <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
1118 age<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
1119 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
1120 message<span class="token punctuation">:</span> <span class="token string">'大于18岁'</span><span class="token punctuation">,</span>
1121 <span class="token function-variable function">validator</span><span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token parameter">rule<span class="token punctuation">,</span> value</span><span class="token punctuation">)</span> <span class="token operator">=></span> value <span class="token operator">></span> <span class="token number">18</span>
1122 <span class="token punctuation">}</span><span class="token punctuation">]</span>
1123 <span class="token punctuation">}</span><span class="token punctuation">}</span>
1124 effects<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span>
1125 <span class="token punctuation">{</span>
1126 field<span class="token punctuation">:</span> <span class="token string">'username'</span><span class="token punctuation">,</span>
1127 <span class="token function-variable function">handler</span><span class="token punctuation">:</span> <span class="token parameter">formCore</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
1128 <span class="token keyword">const</span> name <span class="token operator">=</span> formCore<span class="token punctuation">.</span><span class="token function">getFieldValue</span><span class="token punctuation">(</span><span class="token string">'username'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1129 <span class="token keyword">if</span> <span class="token punctuation">(</span>name <span class="token operator">===</span> <span class="token string">'Khaleesi'</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1130 formCore<span class="token punctuation">.</span><span class="token function">setFieldValue</span><span class="token punctuation">(</span><span class="token string">'age'</span><span class="token punctuation">,</span> <span class="token number">28</span><span class="token punctuation">)</span>
1131 <span class="token punctuation">}</span>
1132 <span class="token punctuation">}</span>
1133 <span class="token punctuation">}</span><span class="token punctuation">,</span>
1134 <span class="token punctuation">{</span>
1135 field<span class="token punctuation">:</span> <span class="token string">'gender'</span><span class="token punctuation">,</span>
1136 <span class="token function-variable function">handler</span><span class="token punctuation">:</span> <span class="token parameter">formCore</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
1137 <span class="token keyword">const</span> gender <span class="token operator">=</span> formCore<span class="token punctuation">.</span><span class="token function">getFieldValue</span><span class="token punctuation">(</span><span class="token string">'gender'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1138 <span class="token keyword">if</span> <span class="token punctuation">(</span>gender <span class="token operator">===</span> <span class="token string">'female'</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1139 formCore<span class="token punctuation">.</span><span class="token function">setFieldProps</span><span class="token punctuation">(</span><span class="token string">'age'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
1140 visible<span class="token punctuation">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span>
1141 <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1142 <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
1143 formCore<span class="token punctuation">.</span><span class="token function">setFieldProps</span><span class="token punctuation">(</span><span class="token string">'age'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
1144 visible<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
1145 <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1146 <span class="token punctuation">}</span>
1147 <span class="token punctuation">}</span>
1148 <span class="token punctuation">}</span>
1149 <span class="token punctuation">]</span><span class="token punctuation">}</span>
1150 <span class="token operator">></span>
1151 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>个人资料<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
1152 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>姓名:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>username<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1153 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>性别:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>gender<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Radio<span class="token punctuation">.</span>Group<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
1154 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Radio</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>male<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Radio</span></span><span class="token punctuation">></span></span>
1155 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Radio</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>female<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Radio</span></span><span class="token punctuation">></span></span>
1156 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Radio</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>x<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token constant">X</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Radio</span></span><span class="token punctuation">></span></span>
1157 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1158 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1159 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>简介:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">.</span>TextArea<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请简单介绍一下自己的工作经历<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1160 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1161 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1162 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1163 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1164 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1165 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1166 <span class="token punctuation">}</span>
1167<span class="token punctuation">}</span>
1168
1169ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1170 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1171<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1172 </div>
1173 </div>
1174 </div>
1175 </div>
1176 <div class="preview" id="container_province-city">
1177 <h3>省市联动</h3>
1178 <div class="markdown">
1179 <p>省市联动</p>
1180
1181 </div>
1182 <div class="code-box">
1183 <div class="code-box-demo">
1184 <div id="province-city"></div>
1185 </div>
1186 <div class="markdown">
1187 <div class="highlight">
1188 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1189<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1190<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1191<span class="token keyword">import</span> <span class="token punctuation">{</span> Input<span class="token punctuation">,</span> Button<span class="token punctuation">,</span> Select <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
1192
1193<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1194
1195<span class="token keyword">const</span> provinceData <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">'Zhejiang'</span><span class="token punctuation">,</span> <span class="token string">'Hubei'</span><span class="token punctuation">,</span> <span class="token string">'Jiangsu'</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
1196<span class="token keyword">const</span> cityData <span class="token operator">=</span> <span class="token punctuation">{</span>
1197 Zhejiang<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'Hangzhou'</span><span class="token punctuation">,</span> <span class="token string">'Ningbo'</span><span class="token punctuation">,</span> <span class="token string">'Wenzhou'</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
1198 Hubei<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'Wuhan'</span><span class="token punctuation">,</span> <span class="token string">'Yichang'</span><span class="token punctuation">,</span> <span class="token string">'Jingzhou'</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
1199 Jiangsu<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token string">'Nanjing'</span><span class="token punctuation">,</span> <span class="token string">'Suzhou'</span><span class="token punctuation">,</span> <span class="token string">'Zhenjiang'</span><span class="token punctuation">]</span>
1200<span class="token punctuation">}</span><span class="token punctuation">;</span>
1201
1202<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1203 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1204 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1205 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1206 <span class="token punctuation">}</span>
1207
1208 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1209 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1210 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1211 <span class="token operator">&lt;</span>Form
1212 onSubmit<span class="token operator">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span>
1213 effects<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span>
1214 <span class="token punctuation">{</span>
1215 field<span class="token punctuation">:</span> <span class="token string">'province'</span><span class="token punctuation">,</span>
1216 <span class="token function-variable function">handler</span><span class="token punctuation">:</span> <span class="token parameter">formCore</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
1217 <span class="token keyword">const</span> province <span class="token operator">=</span> formCore<span class="token punctuation">.</span><span class="token function">getFieldValue</span><span class="token punctuation">(</span><span class="token string">'province'</span><span class="token punctuation">)</span>
1218 formCore<span class="token punctuation">.</span><span class="token function">setValues</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
1219 city<span class="token punctuation">:</span> <span class="token string">''</span><span class="token punctuation">,</span>
1220 population<span class="token punctuation">:</span> <span class="token number">0</span>
1221 <span class="token punctuation">}</span><span class="token punctuation">)</span>
1222 formCore<span class="token punctuation">.</span><span class="token function">setFieldProps</span><span class="token punctuation">(</span><span class="token string">'city'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>dataSource<span class="token punctuation">:</span> cityData<span class="token punctuation">[</span>province<span class="token punctuation">]</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
1223 <span class="token punctuation">}</span>
1224 <span class="token punctuation">}</span><span class="token punctuation">,</span>
1225 <span class="token punctuation">{</span>
1226 field<span class="token punctuation">:</span> <span class="token string">'city'</span><span class="token punctuation">,</span>
1227 <span class="token function-variable function">handler</span><span class="token punctuation">:</span> <span class="token parameter">formCore</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
1228 <span class="token keyword">const</span> city <span class="token operator">=</span> formCore<span class="token punctuation">.</span><span class="token function">getFieldValue</span><span class="token punctuation">(</span><span class="token string">'city'</span><span class="token punctuation">)</span>
1229 <span class="token keyword">if</span> <span class="token punctuation">(</span>city <span class="token operator">===</span> <span class="token string">'Suzhou'</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1230 formCore<span class="token punctuation">.</span><span class="token function">setFieldProps</span><span class="token punctuation">(</span><span class="token string">'population'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>disabled<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
1231 formCore<span class="token punctuation">.</span><span class="token function">setFieldValue</span><span class="token punctuation">(</span><span class="token string">'population'</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>
1232 <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
1233 formCore<span class="token punctuation">.</span><span class="token function">setFieldProps</span><span class="token punctuation">(</span><span class="token string">'population'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>disabled<span class="token punctuation">:</span> <span class="token boolean">false</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
1234 <span class="token punctuation">}</span>
1235 <span class="token punctuation">}</span>
1236 <span class="token punctuation">}</span>
1237 <span class="token punctuation">]</span><span class="token punctuation">}</span>
1238 <span class="token operator">></span>
1239 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
1240 marginBottom<span class="token punctuation">:</span> <span class="token number">20</span><span class="token punctuation">,</span>
1241 <span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>当城市为“苏州”,则 disabled 人口<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1242 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>省:<span class="token punctuation">"</span></span> <span class="token attr-name">layout</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>wrapperCol<span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>province<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Select Province<span class="token punctuation">"</span></span> <span class="token attr-name">dataSource</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>provinceData<span class="token punctuation">}</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Select<span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
1243 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>市:<span class="token punctuation">"</span></span> <span class="token attr-name">layout</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>wrapperCol<span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>city<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Select City<span class="token punctuation">"</span></span> <span class="token attr-name">dataSource</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Select<span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
1244 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>人口:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>population<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>The population of the city<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1245 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1246 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1247 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1248 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1249 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1250 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1251 <span class="token punctuation">}</span>
1252<span class="token punctuation">}</span>
1253
1254ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1255 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1256<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1257 </div>
1258 </div>
1259 </div>
1260 </div>
1261 <div class="preview" id="container_complex-linkage">
1262 <h3>复杂联动</h3>
1263 <div class="markdown">
1264 <p>同时监听两个 Field </p>
1265
1266 </div>
1267 <div class="code-box">
1268 <div class="code-box-demo">
1269 <div id="complex-linkage"></div>
1270 </div>
1271 <div class="markdown">
1272 <div class="highlight">
1273 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1274<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1275<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1276<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
1277
1278
1279<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1280
1281<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1282 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1283 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1284 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1285 <span class="token punctuation">}</span>
1286
1287 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1288 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1289 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1290 <span class="token operator">&lt;</span>Form
1291 onSubmit<span class="token operator">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span>
1292 effects<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span>
1293 <span class="token punctuation">{</span>
1294 field<span class="token punctuation">:</span> <span class="token string">'number1'</span><span class="token punctuation">,</span>
1295 <span class="token function-variable function">handler</span><span class="token punctuation">:</span> <span class="token parameter">formCore</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
1296 <span class="token keyword">const</span> value1 <span class="token operator">=</span> formCore<span class="token punctuation">.</span><span class="token function">getFieldValue</span><span class="token punctuation">(</span><span class="token string">'number1'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1297 <span class="token keyword">const</span> value2 <span class="token operator">=</span> formCore<span class="token punctuation">.</span><span class="token function">getFieldValue</span><span class="token punctuation">(</span><span class="token string">'number2'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1298 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">Number</span><span class="token punctuation">(</span>value1<span class="token punctuation">)</span> <span class="token operator">&lt;</span> <span class="token function">Number</span><span class="token punctuation">(</span>value2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1299 formCore<span class="token punctuation">.</span><span class="token function">setFieldError</span><span class="token punctuation">(</span><span class="token string">'number2'</span><span class="token punctuation">,</span> <span class="token string">'number1不能小于number2'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1300 <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
1301 formCore<span class="token punctuation">.</span><span class="token function">setFieldError</span><span class="token punctuation">(</span><span class="token string">'number2'</span><span class="token punctuation">,</span> <span class="token keyword">undefined</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1302 <span class="token punctuation">}</span>
1303 <span class="token punctuation">}</span>
1304 <span class="token punctuation">}</span><span class="token punctuation">,</span>
1305 <span class="token punctuation">{</span>
1306 field<span class="token punctuation">:</span> <span class="token string">'number2'</span><span class="token punctuation">,</span>
1307 <span class="token function-variable function">handler</span><span class="token punctuation">:</span> <span class="token parameter">formCore</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
1308 <span class="token keyword">const</span> value1 <span class="token operator">=</span> formCore<span class="token punctuation">.</span><span class="token function">getFieldValue</span><span class="token punctuation">(</span><span class="token string">'number1'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1309 <span class="token keyword">const</span> value2 <span class="token operator">=</span> formCore<span class="token punctuation">.</span><span class="token function">getFieldValue</span><span class="token punctuation">(</span><span class="token string">'number2'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1310 <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">Number</span><span class="token punctuation">(</span>value1<span class="token punctuation">)</span> <span class="token operator">&lt;</span> <span class="token function">Number</span><span class="token punctuation">(</span>value2<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1311 formCore<span class="token punctuation">.</span><span class="token function">setFieldError</span><span class="token punctuation">(</span><span class="token string">'number2'</span><span class="token punctuation">,</span> <span class="token string">'number1不能小于number2'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1312 <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
1313 formCore<span class="token punctuation">.</span><span class="token function">setFieldError</span><span class="token punctuation">(</span><span class="token string">'number2'</span><span class="token punctuation">,</span> <span class="token keyword">undefined</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1314 <span class="token punctuation">}</span>
1315 <span class="token punctuation">}</span>
1316 <span class="token punctuation">}</span>
1317 <span class="token punctuation">]</span><span class="token punctuation">}</span>
1318 <span class="token operator">></span>
1319 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Number1:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number1<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number1 必须大于等于 number2<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1320 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Number2:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number2<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number2 必须小于等于 number1<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1321 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1322 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1323 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1324 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1325 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1326 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1327 <span class="token punctuation">}</span>
1328<span class="token punctuation">}</span>
1329
1330ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1331 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1332<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1333 </div>
1334 </div>
1335 </div>
1336 </div>
1337 <div class="preview" id="container_custom-field-layout">
1338 <h3>自定义 Field 布局</h3>
1339 <div class="markdown">
1340 <p>通过 Form 的 renderField 自定义 Field 布局</p>
1341
1342 </div>
1343 <div class="code-box">
1344 <div class="code-box-demo">
1345 <div id="custom-field-layout"></div>
1346 </div>
1347 <div class="markdown">
1348 <div class="highlight">
1349 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1350<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1351<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1352<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
1353
1354<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1355
1356<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1357 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1358 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1359 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1360 <span class="token punctuation">}</span>
1361
1362 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1363 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1364 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1365 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
1366 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
1367 <span class="token attr-name">renderField</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span>label<span class="token punctuation">,</span> component<span class="token punctuation">,</span> error<span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">(</span>
1368 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>marginBottom<span class="token punctuation">:</span> <span class="token string">'10px'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
1369 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span><span class="token punctuation">{</span>label<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1370 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span><span class="token punctuation">></span></span><span class="token punctuation">{</span>component<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
1371 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>color<span class="token punctuation">:</span> <span class="token string">'#ee7893'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span>error<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
1372 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1373 <span class="token punctuation">)</span><span class="token punctuation">}</span></span>
1374 <span class="token attr-name">rules</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
1375 username<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
1376 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
1377 min<span class="token punctuation">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
1378 message<span class="token punctuation">:</span> <span class="token string">'姓名至少5个字符'</span>
1379 <span class="token punctuation">}</span><span class="token punctuation">]</span>
1380 <span class="token punctuation">}</span><span class="token punctuation">}</span></span>
1381 <span class="token punctuation">></span></span>
1382 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>姓名:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>username<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1383 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1384 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1385 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1386 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1387 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1388 <span class="token punctuation">}</span>
1389<span class="token punctuation">}</span>
1390
1391ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1392 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1393<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1394 </div>
1395 </div>
1396 </div>
1397 </div>
1398 <div class="preview" id="container_value-formatter">
1399 <h3>格式化 Field 值</h3>
1400 <div class="markdown">
1401 <p>Format Feild&#39;s value</p>
1402
1403 </div>
1404 <div class="code-box">
1405 <div class="code-box-demo">
1406 <div id="value-formatter"></div>
1407 </div>
1408 <div class="markdown">
1409 <div class="highlight">
1410 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1411<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1412<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1413<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> DatePicker<span class="token punctuation">,</span> Input <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
1414
1415<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1416
1417<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1418 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1419 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1420 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1421 <span class="token punctuation">}</span>
1422
1423 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1424 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1425 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1426 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span> <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
1427 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>姓名显示、存储均为小写,日期存储格式为时间戳<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
1428 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name<span class="token punctuation">"</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>姓名:<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入姓名<span class="token punctuation">"</span></span> <span class="token attr-name">setValueFormatter</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>
1429 <span class="token parameter">value</span> <span class="token operator">=></span> value <span class="token operator">&amp;&amp;</span> value<span class="token punctuation">.</span><span class="token function">toLowerCase</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
1430 <span class="token punctuation">}</span></span> <span class="token attr-name">getValueFormatter</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>
1431 <span class="token parameter">value</span> <span class="token operator">=></span> value <span class="token operator">&amp;&amp;</span> value<span class="token punctuation">.</span><span class="token function">toLowerCase</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
1432 <span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
1433 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>生日:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>date<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>DatePicker<span class="token punctuation">}</span></span> <span class="token attr-name">getValueFormatter</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>
1434 <span class="token parameter">value</span> <span class="token operator">=></span> Date<span class="token punctuation">.</span><span class="token function">parse</span><span class="token punctuation">(</span>value<span class="token punctuation">)</span>
1435 <span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
1436 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1437 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1438 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1439 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1440 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1441 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1442 <span class="token punctuation">}</span>
1443<span class="token punctuation">}</span>
1444
1445ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1446 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1447<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1448 </div>
1449 </div>
1450 </div>
1451 </div>
1452 <div class="preview" id="container_reusable-field-groups">
1453 <h3>复用 Field 组</h3>
1454 <div class="markdown">
1455
1456 </div>
1457 <div class="code-box">
1458 <div class="code-box-demo">
1459 <div id="reusable-field-groups"></div>
1460 </div>
1461 <div class="markdown">
1462 <div class="highlight">
1463 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1464<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1465<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1466<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
1467
1468<span class="token keyword">const</span> <span class="token function-variable function">Address</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> name<span class="token punctuation">,</span> label <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">(</span>
1469 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">React.Fragment</span></span><span class="token punctuation">></span></span>
1470 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1471 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span>
1472 <span class="token attr-name">name</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token template-string"><span class="token string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>name<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">.street`</span></span><span class="token punctuation">}</span></span>
1473 <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span>
1474 <span class="token attr-name">label</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token template-string"><span class="token string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>label<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string"> Street:`</span></span><span class="token punctuation">}</span></span>
1475 <span class="token attr-name">placeholder</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token template-string"><span class="token string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>label<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string"> Street`</span></span><span class="token punctuation">}</span></span>
1476 <span class="token punctuation">/></span></span>
1477 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1478 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1479 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span>
1480 <span class="token attr-name">name</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token template-string"><span class="token string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>name<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">.city`</span></span><span class="token punctuation">}</span></span>
1481 <span class="token attr-name">label</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token template-string"><span class="token string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>label<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string"> City:`</span></span><span class="token punctuation">}</span></span>
1482 <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span>
1483 <span class="token attr-name">placeholder</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token template-string"><span class="token string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>label<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string"> City`</span></span><span class="token punctuation">}</span></span>
1484 <span class="token punctuation">/></span></span>
1485 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1486 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1487 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span>
1488 <span class="token attr-name">name</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token template-string"><span class="token string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>name<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">.postalCode`</span></span><span class="token punctuation">}</span></span>
1489 <span class="token attr-name">label</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token template-string"><span class="token string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>label<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string"> Postal Code:`</span></span><span class="token punctuation">}</span></span>
1490 <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span>
1491 <span class="token attr-name">placeholder</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token template-string"><span class="token string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>label<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string"> Postal Code`</span></span><span class="token punctuation">}</span></span>
1492 <span class="token punctuation">/></span></span>
1493 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1494 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">React.Fragment</span></span><span class="token punctuation">></span></span>
1495<span class="token punctuation">)</span>
1496
1497<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1498
1499<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1500 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1501 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1502 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1503 <span class="token punctuation">}</span>
1504
1505 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1506 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1507 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1508 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span> <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
1509 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span>可复用的 Field Group<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span>
1510 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Address</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>billing<span class="token punctuation">"</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Billing<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1511 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Address</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>shipping<span class="token punctuation">"</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Shipping<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1512 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1513 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1514 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1515 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1516 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1517 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1518 <span class="token punctuation">}</span>
1519<span class="token punctuation">}</span>
1520
1521ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1522 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1523<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1524 </div>
1525 </div>
1526 </div>
1527 </div>
1528 <div class="preview" id="container_loading-value">
1529 <h3>异步加载数据渲染</h3>
1530 <div class="markdown">
1531 <p>异步加载数据进行首屏渲染</p>
1532
1533 </div>
1534 <div class="code-box">
1535 <div class="code-box-demo">
1536 <div id="loading-value"></div>
1537 </div>
1538 <div class="markdown">
1539 <div class="highlight">
1540 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1541<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1542<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1543<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
1544
1545<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1546
1547<span class="token keyword">const</span> <span class="token function-variable function">load</span> <span class="token operator">=</span> <span class="token keyword">async</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
1548 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">2000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1549 <span class="token keyword">return</span> <span class="token punctuation">{</span>
1550 name<span class="token punctuation">:</span> <span class="token string">'erikras'</span><span class="token punctuation">,</span>
1551 age<span class="token punctuation">:</span> <span class="token number">20</span><span class="token punctuation">,</span>
1552 desc<span class="token punctuation">:</span> <span class="token string">'我是 erikras'</span>
1553 <span class="token punctuation">}</span><span class="token punctuation">;</span>
1554<span class="token punctuation">}</span>
1555
1556<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1557 state <span class="token operator">=</span> <span class="token punctuation">{</span> data<span class="token punctuation">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token punctuation">}</span>
1558
1559 <span class="token keyword">async</span> <span class="token function">componentDidMount</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1560 <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span> loading<span class="token punctuation">:</span> <span class="token boolean">true</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1561 <span class="token keyword">const</span> data <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">load</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1562 <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span> loading<span class="token punctuation">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span> data <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1563 <span class="token punctuation">}</span>
1564
1565 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1566 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1567 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1568 <span class="token punctuation">}</span>
1569
1570 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1571 <span class="token keyword">const</span> Age <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>color<span class="token punctuation">:</span> <span class="token string">'green'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>年龄:<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1572 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1573 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1574 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>加载表单数据并且初始化(label支持自定义jsx)<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
1575 <span class="token operator">&lt;</span>Form
1576 initialValues<span class="token operator">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">.</span>data<span class="token punctuation">}</span>
1577 onSubmit<span class="token operator">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span>
1578 effects<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span><span class="token punctuation">{</span>
1579 field<span class="token punctuation">:</span> <span class="token string">'name'</span><span class="token punctuation">,</span>
1580 <span class="token function-variable function">handler</span><span class="token punctuation">:</span> <span class="token parameter">formCore</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
1581 <span class="token keyword">const</span> name <span class="token operator">=</span> formCore<span class="token punctuation">.</span><span class="token function">getFieldValue</span><span class="token punctuation">(</span><span class="token string">'name'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1582 <span class="token keyword">if</span> <span class="token punctuation">(</span>name <span class="token operator">===</span> <span class="token string">'erikras'</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1583 formCore<span class="token punctuation">.</span><span class="token function">setFieldValue</span><span class="token punctuation">(</span><span class="token string">'age'</span><span class="token punctuation">,</span> <span class="token number">28</span><span class="token punctuation">)</span>
1584 <span class="token punctuation">}</span>
1585 <span class="token punctuation">}</span>
1586 <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">}</span>
1587 <span class="token operator">></span>
1588 <span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">.</span>loading <span class="token operator">&amp;&amp;</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>loading<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>loading<span class="token operator">...</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span><span class="token punctuation">}</span>
1589 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name<span class="token punctuation">"</span></span> <span class="token attr-name">label</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>color<span class="token punctuation">:</span> <span class="token string">'red'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>名称:<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span><span class="token punctuation">}</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1590 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">label</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Age<span class="token punctuation">}</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1591 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>desc<span class="token punctuation">"</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>简介:<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">.</span>TextArea<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请简单介绍一下自己的工作经历<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1592 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1593 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1594 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1595 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1596 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1597 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1598 <span class="token punctuation">}</span>
1599<span class="token punctuation">}</span>
1600
1601ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1602 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1603<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1604 </div>
1605 </div>
1606 </div>
1607 </div>
1608 <div class="preview" id="container_dialog-form">
1609 <h3>Dialog 表单</h3>
1610 <div class="markdown">
1611 <p>Form 结合对话框</p>
1612
1613 </div>
1614 <div class="code-box">
1615 <div class="code-box-demo">
1616 <div id="dialog-form"></div>
1617 </div>
1618 <div class="markdown">
1619 <div class="highlight">
1620 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1621<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1622<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1623<span class="token keyword">import</span> <span class="token punctuation">{</span> Input<span class="token punctuation">,</span> Button<span class="token punctuation">,</span> Dialog<span class="token punctuation">,</span> Switch <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
1624
1625<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1626
1627<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1628 handleSubmit <span class="token operator">=</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
1629
1630 state <span class="token operator">=</span> <span class="token punctuation">{</span>
1631 visible<span class="token punctuation">:</span> <span class="token boolean">false</span>
1632 <span class="token punctuation">}</span><span class="token punctuation">;</span>
1633
1634 <span class="token function-variable function">onOpen</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
1635 <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
1636 visible<span class="token punctuation">:</span> <span class="token boolean">true</span>
1637 <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1638 <span class="token punctuation">}</span><span class="token punctuation">;</span>
1639
1640 <span class="token function-variable function">onClose</span> <span class="token operator">=</span> <span class="token parameter">reason</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
1641 <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
1642 visible<span class="token punctuation">:</span> <span class="token boolean">false</span>
1643 <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1644 <span class="token punctuation">}</span><span class="token punctuation">;</span>
1645
1646 <span class="token function-variable function">onOk</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
1647 <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">handleSubmit</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span><span class="token punctuation">;</span>
1648 <span class="token punctuation">}</span><span class="token punctuation">;</span>
1649
1650 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1651 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1652 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1653 <span class="token punctuation">}</span>
1654
1655 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1656 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1657 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1658 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onOpen<span class="token punctuation">}</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1659 Open dialog
1660 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1661 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Dialog</span></span>
1662 <span class="token attr-name">title</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>表单 Form 对话框<span class="token punctuation">"</span></span>
1663 <span class="token attr-name">visible</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">.</span>visible<span class="token punctuation">}</span></span>
1664 <span class="token attr-name">onOk</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">onOk</span><span class="token punctuation">.</span><span class="token function">bind</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span>
1665 <span class="token attr-name">onCancel</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">onClose</span><span class="token punctuation">.</span><span class="token function">bind</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> <span class="token string">'cancelClick'</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span>
1666 <span class="token attr-name">onClose</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onClose<span class="token punctuation">}</span></span>
1667 <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
1668 width<span class="token punctuation">:</span> <span class="token number">600</span><span class="token punctuation">,</span>
1669 <span class="token punctuation">}</span><span class="token punctuation">}</span></span>
1670 <span class="token punctuation">></span></span>
1671 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
1672 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
1673 <span class="token attr-name">layout</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
1674 labelCol<span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">,</span>
1675 wrapperCol<span class="token punctuation">:</span> <span class="token number">8</span>
1676 <span class="token punctuation">}</span><span class="token punctuation">}</span></span>
1677 <span class="token punctuation">></span></span>
1678 <span class="token punctuation">{</span><span class="token parameter">formCore</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
1679 <span class="token keyword">this</span><span class="token punctuation">.</span>handleSubmit <span class="token operator">=</span> formCore<span class="token punctuation">.</span><span class="token function">submit</span><span class="token punctuation">.</span><span class="token function">bind</span><span class="token punctuation">(</span>formCore<span class="token punctuation">)</span><span class="token punctuation">;</span>
1680 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1681 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1682 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name<span class="token punctuation">"</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>名称:<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1683 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1684 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>desc<span class="token punctuation">"</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>简介:<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">.</span>TextArea<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请简单介绍一下自己的工作经历<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1685 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>open<span class="token punctuation">"</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>是否打开:<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Switch<span class="token punctuation">}</span></span> <span class="token attr-name">valueName</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>checked<span class="token punctuation">"</span></span> <span class="token attr-name">value</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token boolean">true</span><span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
1686 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>openDesc<span class="token punctuation">"</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>打开时的描述:<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>description when opening<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span>
1687 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>closeDesc<span class="token punctuation">"</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>关闭时的描述:<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>description when closing<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1688 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1689 <span class="token punctuation">)</span>
1690 <span class="token punctuation">}</span><span class="token punctuation">}</span>
1691 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1692 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Dialog</span></span><span class="token punctuation">></span></span>
1693 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1694 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1695 <span class="token punctuation">}</span>
1696<span class="token punctuation">}</span>
1697
1698ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1699 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1700<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1701 </div>
1702 </div>
1703 </div>
1704 </div>
1705 <div class="preview" id="container_antd-component">
1706 <h3>结合 Antd 组件</h3>
1707 <div class="markdown">
1708 <p>使用 Antd 组件</p>
1709
1710 </div>
1711 <div class="code-box">
1712 <div class="code-box-demo">
1713 <div id="antd-component"></div>
1714 </div>
1715 <div class="markdown">
1716 <div class="highlight">
1717 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1718<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1719<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1720<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input<span class="token punctuation">,</span> Select<span class="token punctuation">,</span> Switch<span class="token punctuation">,</span> Checkbox<span class="token punctuation">,</span> Radio <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'antd'</span><span class="token punctuation">;</span>
1721<span class="token keyword">import</span> <span class="token string">'antd/dist/antd.css'</span><span class="token punctuation">;</span>
1722
1723<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1724
1725<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1726 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1727 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1728 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1729 <span class="token punctuation">}</span>
1730
1731 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1732 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1733 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1734 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
1735 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
1736 <span class="token punctuation">></span></span>
1737 <span class="token punctuation">{</span><span class="token parameter">formCore</span> <span class="token operator">=></span> <span class="token punctuation">(</span>
1738 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1739 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>Antd 组件<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
1740 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>姓名:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>username<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1741 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1742 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>简介:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">.</span>TextArea<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请简单介绍一下自己的工作经历<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1743 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>性别:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>gender<span class="token punctuation">"</span></span> <span class="token attr-name">rules</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span><span class="token punctuation">{</span>
1744 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
1745 message<span class="token punctuation">:</span> <span class="token string">'性别必选'</span>
1746 <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Radio<span class="token punctuation">.</span>Group<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
1747 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Radio</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>apple<span class="token punctuation">"</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>male<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Male<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Radio</span></span><span class="token punctuation">></span></span>
1748 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Radio</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>watermelon<span class="token punctuation">"</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>female<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Female<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Radio</span></span><span class="token punctuation">></span></span>
1749 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Radio</span></span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>orange<span class="token punctuation">"</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>x<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token constant">X</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Radio</span></span><span class="token punctuation">></span></span>
1750 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1751 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>前端框架:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>framework<span class="token punctuation">"</span></span> <span class="token attr-name">value</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Checkbox<span class="token punctuation">.</span>Group<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
1752 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>react<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>React<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>
1753 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>vue<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Vue<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>
1754 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>angular<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Angular<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>
1755 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1756 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>加班:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>switch<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Switch<span class="token punctuation">}</span></span> <span class="token attr-name">valueName</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">'</span>checked<span class="token punctuation">'</span></span> <span class="token attr-name">value</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token boolean">true</span><span class="token punctuation">}</span></span> <span class="token attr-name">checkedChildren</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>on<span class="token punctuation">"</span></span> <span class="token attr-name">unCheckedChildren</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>off<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1757 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>职级:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>grade<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Select<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
1758 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Select.Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>p6<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token constant">P6</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Select.Option</span></span><span class="token punctuation">></span></span>
1759 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Select.Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>p7<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token constant">P7</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Select.Option</span></span><span class="token punctuation">></span></span>
1760 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Select.Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>p8<span class="token punctuation">"</span></span> <span class="token attr-name">disabled</span><span class="token punctuation">></span></span><span class="token constant">P8</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Select.Option</span></span><span class="token punctuation">></span></span>
1761 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1762 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1763 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1764 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1765 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1766 <span class="token punctuation">)</span><span class="token punctuation">}</span>
1767 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1768 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1769 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1770 <span class="token punctuation">}</span>
1771<span class="token punctuation">}</span>
1772
1773ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1774 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1775<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1776 </div>
1777 </div>
1778 </div>
1779 </div>
1780 <div class="preview" id="container_raw-html">
1781 <h3>原生 html 标签</h3>
1782 <div class="markdown">
1783 <p>使用原生 html 标签</p>
1784
1785 </div>
1786 <div class="code-box">
1787 <div class="code-box-demo">
1788 <div id="raw-html"></div>
1789 </div>
1790 <div class="markdown">
1791 <div class="highlight">
1792 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1793<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1794<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1795
1796<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1797
1798<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1799 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1800 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1801 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1802 <span class="token punctuation">}</span>
1803
1804 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1805 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1806 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1807 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
1808 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
1809 <span class="token attr-name">rules</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
1810 username<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
1811 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
1812 min<span class="token punctuation">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
1813 message<span class="token punctuation">:</span> <span class="token string">'姓名至少5个字符'</span>
1814 <span class="token punctuation">}</span><span class="token punctuation">]</span>
1815 <span class="token punctuation">}</span><span class="token punctuation">}</span></span>
1816 <span class="token punctuation">></span></span>
1817 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>个人资料<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
1818 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>姓名:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>username<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>input<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1819 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>input<span class="token punctuation">"</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1820 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>简介:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>textarea<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请简单介绍一下自己的工作经历<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1821 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>框架:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>framework<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>select<span class="token punctuation">"</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>react<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1822 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>vue<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Vue<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">></span></span>
1823 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>react<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>React<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">></span></span>
1824 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>option</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>angular<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Angular<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>option</span><span class="token punctuation">></span></span>
1825 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1826 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>ICE背景:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>ice<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>input<span class="token punctuation">"</span></span> <span class="token attr-name">valueName</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">'</span>checked<span class="token punctuation">'</span></span> <span class="token attr-name">value</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token boolean">false</span><span class="token punctuation">}</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>radio<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1827 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1828 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>button</span><span class="token punctuation">></span></span>
1829 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1830 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1831 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1832 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1833 <span class="token punctuation">}</span>
1834<span class="token punctuation">}</span>
1835
1836ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1837 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1838<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1839 </div>
1840 </div>
1841 </div>
1842 </div>
1843 <div class="preview" id="container_async-form-props">
1844 <h3>异步更新 Form props</h3>
1845 <div class="markdown">
1846
1847 </div>
1848 <div class="code-box">
1849 <div class="code-box-demo">
1850 <div id="async-form-props"></div>
1851 </div>
1852 <div class="markdown">
1853 <div class="highlight">
1854 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1855<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1856<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1857<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
1858
1859<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1860
1861<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1862 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1863 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1864 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1865 <span class="token punctuation">}</span>
1866
1867 state <span class="token operator">=</span> <span class="token punctuation">{</span>
1868 renderField<span class="token punctuation">:</span> <span class="token keyword">undefined</span><span class="token punctuation">,</span>
1869 data<span class="token punctuation">:</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
1870 rules<span class="token punctuation">:</span> <span class="token punctuation">{</span>
1871 username<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
1872 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
1873 min<span class="token punctuation">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
1874 message<span class="token punctuation">:</span> <span class="token string">'姓名至少5个字符'</span>
1875 <span class="token punctuation">}</span><span class="token punctuation">]</span>
1876 <span class="token punctuation">}</span>
1877 <span class="token punctuation">}</span>
1878
1879 <span class="token keyword">async</span> <span class="token function">componentDidMount</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1880 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
1881 <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
1882 <span class="token function-variable function">renderField</span><span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span>label<span class="token punctuation">,</span> component<span class="token punctuation">,</span> error<span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">(</span>
1883 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>marginBottom<span class="token punctuation">:</span> <span class="token string">'15px'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
1884 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span><span class="token punctuation">{</span>label<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1885 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span><span class="token punctuation">></span></span><span class="token punctuation">{</span>component<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
1886 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>marginLeft<span class="token punctuation">:</span> <span class="token string">'10px'</span><span class="token punctuation">,</span> color<span class="token punctuation">:</span> <span class="token string">'#ee7893'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span>error<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
1887 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1888 <span class="token punctuation">)</span><span class="token punctuation">,</span>
1889 data<span class="token punctuation">:</span> <span class="token punctuation">{</span>
1890 username<span class="token punctuation">:</span> <span class="token string">'erikras'</span><span class="token punctuation">,</span>
1891 age<span class="token punctuation">:</span> <span class="token number">20</span><span class="token punctuation">,</span>
1892 desc<span class="token punctuation">:</span> <span class="token string">'我是 erikras'</span>
1893 <span class="token punctuation">}</span><span class="token punctuation">,</span>
1894 rules<span class="token punctuation">:</span> <span class="token punctuation">{</span>
1895 username<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
1896 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
1897 min<span class="token punctuation">:</span> <span class="token number">10</span><span class="token punctuation">,</span>
1898 message<span class="token punctuation">:</span> <span class="token string">'姓名至少10个字符'</span>
1899 <span class="token punctuation">}</span><span class="token punctuation">]</span>
1900 <span class="token punctuation">}</span>
1901 <span class="token punctuation">}</span><span class="token punctuation">)</span>
1902 <span class="token punctuation">}</span>
1903
1904 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1905 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1906 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1907 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
1908 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
1909 <span class="token attr-name">initialValues</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">.</span>data<span class="token punctuation">}</span></span>
1910 <span class="token attr-name">renderField</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">.</span>renderField<span class="token punctuation">}</span></span>
1911 <span class="token attr-name">rules</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">.</span>rules<span class="token punctuation">}</span></span>
1912 <span class="token punctuation">></span></span>
1913 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>姓名:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>username<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1914 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1915 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>简介: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>desc<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">.</span>TextArea<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请简单介绍一下自己的工作经历<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1916 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1917 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1918 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1919 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1920 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1921 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1922 <span class="token punctuation">}</span>
1923<span class="token punctuation">}</span>
1924
1925ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1926 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1927<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1928 </div>
1929 </div>
1930 </div>
1931 </div>
1932 <div class="preview" id="container_layout">
1933 <h3>表单布局</h3>
1934 <div class="markdown">
1935 <p>表单布局</p>
1936
1937 </div>
1938 <div class="code-box">
1939 <div class="code-box-demo">
1940 <div id="layout"></div>
1941 </div>
1942 <div class="markdown">
1943 <div class="highlight">
1944 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
1945<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
1946<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
1947<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
1948
1949<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
1950
1951<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
1952 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1953 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
1954 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
1955 <span class="token punctuation">}</span>
1956
1957 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
1958 <span class="token keyword">const</span> layout <span class="token operator">=</span> <span class="token punctuation">{</span>
1959 labelCol<span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">,</span>
1960 wrapperCol<span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">,</span>
1961 labelTextAlign<span class="token punctuation">:</span> <span class="token string">'left'</span><span class="token punctuation">,</span>
1962 labelAlign<span class="token punctuation">:</span> <span class="token string">'top'</span>
1963 <span class="token punctuation">}</span><span class="token punctuation">;</span>
1964 <span class="token keyword">return</span> <span class="token punctuation">(</span>
1965 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
1966 <span class="token operator">&lt;</span>Form
1967 layout <span class="token operator">=</span> <span class="token punctuation">{</span>layout<span class="token punctuation">}</span>
1968 onSubmit<span class="token operator">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span>
1969 rules<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
1970 username<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
1971 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
1972 min<span class="token punctuation">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
1973 message<span class="token punctuation">:</span> <span class="token string">'姓名至少5个字符'</span>
1974 <span class="token punctuation">}</span><span class="token punctuation">]</span>
1975 <span class="token punctuation">}</span><span class="token punctuation">}</span>
1976 <span class="token operator">></span>
1977 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>个人资料<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
1978 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>姓名:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>username<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span> <span class="token attr-name">errorRender</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>
1979 <span class="token parameter">error</span> <span class="token operator">=></span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>color<span class="token punctuation">:</span> <span class="token string">'#ff7000'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span>error<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
1980 <span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
1981 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">tips</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>身份证上的年龄<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1982 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>简介:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">.</span>TextArea<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请简单介绍一下自己的工作经历<span class="token punctuation">"</span></span> <span class="token attr-name">tips</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>介绍自己的经历介绍自己的经历介绍自己的经历介绍自己的经历<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
1983 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
1984 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
1985 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
1986 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
1987 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
1988 <span class="token punctuation">)</span><span class="token punctuation">;</span>
1989 <span class="token punctuation">}</span>
1990<span class="token punctuation">}</span>
1991
1992ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
1993 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
1994<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
1995 </div>
1996 </div>
1997 </div>
1998 </div>
1999 <div class="preview" id="container_label-layout">
2000 <h3>标签布局</h3>
2001 <div class="markdown">
2002 <p>标签布局,当前支持 labelTextAlign 和 labelAlign</p>
2003
2004 </div>
2005 <div class="code-box">
2006 <div class="code-box-demo">
2007 <div id="label-layout"></div>
2008 </div>
2009 <div class="markdown">
2010 <div class="highlight">
2011 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
2012<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
2013<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
2014<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
2015
2016<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
2017 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2018 <span class="token keyword">return</span> <span class="token punctuation">(</span>
2019 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
2020 <span class="token operator">&lt;</span>Form
2021 layout <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">{</span>
2022 labelTextAlign<span class="token punctuation">:</span> <span class="token string">'left'</span>
2023 <span class="token punctuation">}</span><span class="token punctuation">}</span>
2024 <span class="token operator">></span>
2025 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span><span class="token function">标签靠左</span><span class="token punctuation">(</span>labelTextAlign<span class="token punctuation">:</span> left<span class="token punctuation">)</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
2026 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>please input name<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2027 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>please input age<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2028 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>please input intro<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2029 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
2030 <span class="token operator">&lt;</span>Form
2031 layout <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">{</span>
2032 labelTextAlign<span class="token punctuation">:</span> <span class="token string">'right'</span>
2033 <span class="token punctuation">}</span><span class="token punctuation">}</span>
2034 <span class="token operator">></span>
2035 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span><span class="token function">标签靠右</span><span class="token punctuation">(</span>labelTextAlign<span class="token punctuation">:</span> right<span class="token punctuation">)</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
2036 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>please input name<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2037 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>please input age<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2038 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>please input intro<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2039 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
2040 <span class="token operator">&lt;</span>Form
2041 layout <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">{</span>
2042 labelAlign<span class="token punctuation">:</span> <span class="token string">'top'</span><span class="token punctuation">,</span>
2043 labelTextAlign<span class="token punctuation">:</span> <span class="token string">'left'</span>
2044 <span class="token punctuation">}</span><span class="token punctuation">}</span>
2045 <span class="token operator">></span>
2046 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span><span class="token function">标签在上面</span><span class="token punctuation">(</span>labelAlign<span class="token punctuation">:</span> top<span class="token punctuation">)</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
2047 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>please input name<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2048 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>please input age<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2049 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>please input intro<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2050 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
2051 <span class="token operator">&lt;</span>Form
2052 layout <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">{</span>
2053 labelAlign<span class="token punctuation">:</span> <span class="token string">'left'</span>
2054 <span class="token punctuation">}</span><span class="token punctuation">}</span>
2055 <span class="token operator">></span>
2056 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span><span class="token function">标签在左边</span><span class="token punctuation">(</span>labelAlign<span class="token punctuation">:</span> left<span class="token punctuation">)</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
2057 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>name<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>please input name<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2058 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>please input age<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2059 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro: <span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>please input intro<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2060 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
2061 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2062 <span class="token punctuation">)</span><span class="token punctuation">;</span>
2063 <span class="token punctuation">}</span>
2064<span class="token punctuation">}</span>
2065
2066ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
2067 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
2068<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
2069 </div>
2070 </div>
2071 </div>
2072 </div>
2073 <div class="preview" id="container_custom-label">
2074 <h3>自定义标签</h3>
2075 <div class="markdown">
2076 <p><code>Form</code> 自定义标签,给每个标签增加必填符号</p>
2077
2078 </div>
2079 <div class="code-box">
2080 <div class="code-box-demo">
2081 <div id="custom-label"></div>
2082 </div>
2083 <div class="markdown">
2084 <div class="highlight">
2085 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
2086<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
2087<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
2088<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input<span class="token punctuation">,</span> Switch<span class="token punctuation">,</span> Select<span class="token punctuation">,</span> Checkbox <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
2089
2090<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
2091
2092<span class="token keyword">const</span> Option <span class="token operator">=</span> Select<span class="token punctuation">.</span>Option<span class="token punctuation">;</span>
2093
2094<span class="token keyword">function</span> <span class="token function">renderLabel</span><span class="token punctuation">(</span><span class="token parameter">name</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2095 <span class="token keyword">return</span> <span class="token punctuation">(</span>
2096 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span><span class="token punctuation">></span></span>
2097 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
2098 color<span class="token punctuation">:</span> <span class="token string">'red'</span><span class="token punctuation">,</span>
2099 <span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token operator">*</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
2100 <span class="token punctuation">{</span>name<span class="token punctuation">}</span>
2101 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
2102 <span class="token punctuation">)</span><span class="token punctuation">;</span>
2103<span class="token punctuation">}</span>
2104
2105<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
2106 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2107 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
2108 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
2109 <span class="token punctuation">}</span>
2110
2111 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2112 <span class="token keyword">return</span> <span class="token punctuation">(</span>
2113 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
2114 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
2115 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
2116 <span class="token attr-name">rules</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
2117 username<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
2118 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
2119 min<span class="token punctuation">:</span> <span class="token number">5</span><span class="token punctuation">,</span>
2120 message<span class="token punctuation">:</span> <span class="token string">'姓名至少5个字符'</span>
2121 <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
2122 age<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
2123 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
2124 message<span class="token punctuation">:</span> <span class="token string">'年纪必填'</span>
2125 <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
2126 intro<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>
2127 required<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
2128 message<span class="token punctuation">:</span> <span class="token string">'简介必填'</span>
2129 <span class="token punctuation">}</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
2130 <span class="token punctuation">}</span><span class="token punctuation">}</span></span>
2131 <span class="token punctuation">></span></span>
2132 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>个人资料<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
2133 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token function">renderLabel</span><span class="token punctuation">(</span><span class="token string">'姓名:'</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>username<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2134 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token function">renderLabel</span><span class="token punctuation">(</span><span class="token string">'年龄:'</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2135 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token function">renderLabel</span><span class="token punctuation">(</span><span class="token string">'简介:'</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>intro<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">.</span>TextArea<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请简单介绍一下自己的工作经历<span class="token punctuation">"</span></span><span class="token punctuation">/></span></span>
2136 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>开关:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>open<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Switch<span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
2137 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>尺寸:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>size<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Select<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请选择尺寸<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
2138 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>small<span class="token punctuation">"</span></span> <span class="token attr-name">key</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>small<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Option</span></span><span class="token punctuation">></span></span>
2139 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>medium<span class="token punctuation">"</span></span> <span class="token attr-name">key</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>medium<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Option</span></span><span class="token punctuation">></span></span>
2140 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>large<span class="token punctuation">"</span></span> <span class="token attr-name">key</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>large<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Option</span></span><span class="token punctuation">></span></span>
2141 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
2142 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>选项:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>checkbox<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Checkbox<span class="token punctuation">.</span>Group<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
2143 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>a<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>选项一<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>
2144 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>b<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>选项二<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>
2145 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">disabled</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>c<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>选项三(disabled)<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>
2146 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
2147 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
2148 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
2149 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
2150 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
2151 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2152 <span class="token punctuation">)</span><span class="token punctuation">;</span>
2153 <span class="token punctuation">}</span>
2154<span class="token punctuation">}</span>
2155
2156ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
2157 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
2158<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
2159 </div>
2160 </div>
2161 </div>
2162 </div>
2163 <div class="preview" id="container_big-form">
2164 <h3>大表单</h3>
2165 <div class="markdown">
2166 <p>输入框后面的数字代表每个 Field 渲染的次数。
2167当在某个 Field 输入内容时,可以看到 form 组件,只有当前的 Field 会重新渲染,而 formBinder 则是所有的 Field 都会重新渲染。form 渲染性能优于 formBinder。</p>
2168
2169 </div>
2170 <div class="code-box">
2171 <div class="code-box-demo">
2172 <div id="big-form"></div>
2173 </div>
2174 <div class="markdown">
2175 <div class="highlight">
2176 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
2177<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
2178<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
2179<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
2180<span class="token keyword">import</span> <span class="token punctuation">{</span> FormBinderWrapper<span class="token punctuation">,</span> FormBinder <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@icedesign/form-binder'</span><span class="token punctuation">;</span>
2181
2182<span class="token keyword">const</span> renderCountStyles <span class="token operator">=</span> <span class="token punctuation">{</span>
2183 position<span class="token punctuation">:</span> <span class="token string">'absolute'</span><span class="token punctuation">,</span>
2184 top<span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
2185 right<span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
2186 fontStyle<span class="token punctuation">:</span> <span class="token string">'normal'</span><span class="token punctuation">,</span>
2187 textAlign<span class="token punctuation">:</span> <span class="token string">'center'</span><span class="token punctuation">,</span>
2188 height<span class="token punctuation">:</span> <span class="token string">'26px'</span><span class="token punctuation">,</span>
2189 width<span class="token punctuation">:</span> <span class="token string">'26px'</span><span class="token punctuation">,</span>
2190 lineHeight<span class="token punctuation">:</span> <span class="token string">'26px'</span><span class="token punctuation">,</span>
2191 borderRadius<span class="token punctuation">:</span> <span class="token string">'13px'</span><span class="token punctuation">,</span>
2192 border<span class="token punctuation">:</span> <span class="token string">'1px solid #ddd'</span><span class="token punctuation">,</span>
2193 background<span class="token punctuation">:</span> <span class="token string">'#eee'</span>
2194<span class="token punctuation">}</span><span class="token punctuation">;</span>
2195
2196<span class="token keyword">class</span> <span class="token class-name">RenderCount</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
2197 renders <span class="token operator">=</span> <span class="token number">0</span>
2198
2199 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2200 <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>renderCountStyles<span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span><span class="token operator">++</span><span class="token keyword">this</span><span class="token punctuation">.</span>renders<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
2201 <span class="token punctuation">}</span>
2202<span class="token punctuation">}</span>
2203
2204<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
2205
2206<span class="token keyword">let</span> dataSource <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
2207<span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> <span class="token number">150</span><span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2208 <span class="token keyword">const</span> item <span class="token operator">=</span> <span class="token punctuation">{</span>
2209 label<span class="token punctuation">:</span> <span class="token template-string"><span class="token string">`Label</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>i<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">`</span></span><span class="token punctuation">,</span>
2210 name<span class="token punctuation">:</span> <span class="token template-string"><span class="token string">`name</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>i<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">`</span></span><span class="token punctuation">,</span>
2211 placeholder<span class="token punctuation">:</span> <span class="token template-string"><span class="token string">`placeholder </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>i<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">`</span></span>
2212 <span class="token punctuation">}</span><span class="token punctuation">;</span>
2213
2214 dataSource<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span>item<span class="token punctuation">)</span><span class="token punctuation">;</span>
2215<span class="token punctuation">}</span>
2216
2217<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
2218 state <span class="token operator">=</span> <span class="token punctuation">{</span>
2219 value<span class="token punctuation">:</span> <span class="token punctuation">{</span>
2220 email<span class="token punctuation">:</span> <span class="token string">''</span><span class="token punctuation">,</span>
2221 name<span class="token punctuation">:</span> <span class="token string">''</span><span class="token punctuation">,</span>
2222 password<span class="token punctuation">:</span> <span class="token string">''</span><span class="token punctuation">,</span>
2223 <span class="token punctuation">}</span><span class="token punctuation">,</span>
2224 isFormBinder<span class="token punctuation">:</span> <span class="token boolean">false</span>
2225 <span class="token punctuation">}</span><span class="token punctuation">;</span>
2226
2227 <span class="token function-variable function">toggle</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
2228 <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
2229 isFormBinder<span class="token punctuation">:</span> <span class="token operator">!</span><span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">.</span>isFormBinder
2230 <span class="token punctuation">}</span><span class="token punctuation">)</span>
2231 <span class="token punctuation">}</span>
2232
2233 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2234 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
2235 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
2236 <span class="token punctuation">}</span>
2237
2238 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2239 <span class="token keyword">return</span> <span class="token punctuation">(</span>
2240 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
2241 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>表单性能测试 form vs formBinder<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
2242 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>toggle<span class="token punctuation">}</span></span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>marginBottom<span class="token punctuation">:</span> <span class="token string">'10px'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>Toggle Form<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
2243 <span class="token punctuation">{</span><span class="token operator">!</span><span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">.</span>isFormBinder <span class="token operator">&amp;&amp;</span> <span class="token punctuation">(</span>
2244 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
2245 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
2246 <span class="token attr-name">renderField</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span>label<span class="token punctuation">,</span> component<span class="token punctuation">,</span> error<span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">(</span>
2247 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>marginBottom<span class="token punctuation">:</span> <span class="token string">'10px'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
2248 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>display<span class="token punctuation">:</span> <span class="token string">'inline-block'</span><span class="token punctuation">,</span> width<span class="token punctuation">:</span> <span class="token string">'80px'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span>label<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
2249 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>position<span class="token punctuation">:</span> <span class="token string">'relative'</span><span class="token punctuation">,</span> display<span class="token punctuation">:</span> <span class="token string">'inline-block'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
2250 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span><span class="token punctuation">></span></span><span class="token punctuation">{</span>component<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
2251 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">RenderCount</span></span> <span class="token punctuation">/></span></span>
2252 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2253 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">RenderCount</span></span> <span class="token punctuation">/></span></span>
2254 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>color<span class="token punctuation">:</span> <span class="token string">'#ee7893'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span>error<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
2255 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2256 <span class="token punctuation">)</span><span class="token punctuation">}</span></span>
2257 <span class="token punctuation">></span></span>
2258 <span class="token punctuation">{</span>
2259 dataSource<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token parameter">field</span> <span class="token operator">=></span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">key</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>field<span class="token punctuation">.</span>name<span class="token punctuation">}</span></span> <span class="token attr-name">name</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>field<span class="token punctuation">.</span>name<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token template-string"><span class="token string">`new form </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>field<span class="token punctuation">.</span>placeholder<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">`</span></span><span class="token punctuation">}</span></span> <span class="token attr-name">label</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>field<span class="token punctuation">.</span>label<span class="token punctuation">}</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span> <span class="token punctuation">)</span>
2260 <span class="token punctuation">}</span>
2261 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
2262 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
2263 <span class="token punctuation">)</span><span class="token punctuation">}</span>
2264
2265 <span class="token punctuation">{</span>
2266 <span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">.</span>isFormBinder <span class="token operator">&amp;&amp;</span> <span class="token punctuation">(</span>
2267 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
2268 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">FormBinderWrapper</span></span>
2269 <span class="token attr-name">value</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">.</span>value<span class="token punctuation">}</span></span>
2270 <span class="token attr-name">ref</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>form<span class="token punctuation">"</span></span>
2271 <span class="token punctuation">></span></span>
2272 <span class="token punctuation">{</span>
2273 dataSource<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token parameter">field</span> <span class="token operator">=></span> <span class="token punctuation">(</span>
2274 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">key</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>field<span class="token punctuation">.</span>name<span class="token punctuation">}</span></span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>marginBottom<span class="token punctuation">:</span> <span class="token string">'10px'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
2275 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>span</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>display<span class="token punctuation">:</span> <span class="token string">'inline-block'</span><span class="token punctuation">,</span> width<span class="token punctuation">:</span> <span class="token string">'80px'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span>field<span class="token punctuation">.</span>label<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>span</span><span class="token punctuation">></span></span>
2276 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">FormBinder</span></span> <span class="token attr-name">name</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>field<span class="token punctuation">.</span>name<span class="token punctuation">}</span></span> <span class="token attr-name">require</span> <span class="token punctuation">></span></span>
2277 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>position<span class="token punctuation">:</span> <span class="token string">'relative'</span><span class="token punctuation">,</span> display<span class="token punctuation">:</span> <span class="token string">'inline'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
2278 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">RenderCount</span></span> <span class="token punctuation">/></span></span>
2279 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Input</span></span> <span class="token attr-name">placeholder</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token template-string"><span class="token string">`formBinder </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>field<span class="token punctuation">.</span>placeholder<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">`</span></span><span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
2280 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2281 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">FormBinder</span></span><span class="token punctuation">></span></span>
2282 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2283 <span class="token punctuation">)</span><span class="token punctuation">)</span>
2284 <span class="token punctuation">}</span>
2285 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">FormBinderWrapper</span></span><span class="token punctuation">></span></span>
2286 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2287 <span class="token punctuation">)</span>
2288 <span class="token punctuation">}</span>
2289 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2290 <span class="token punctuation">)</span><span class="token punctuation">;</span>
2291 <span class="token punctuation">}</span>
2292<span class="token punctuation">}</span>
2293
2294ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
2295 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
2296<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
2297 </div>
2298 </div>
2299 </div>
2300 </div>
2301 <div class="preview" id="container_layout-line-two-fields">
2302 <h3>一行两个 Field</h3>
2303 <div class="markdown">
2304 <style>.ice-inline-form .field-wrapper {
2305 display: flex;
2306 flex-wrap: wrap;
2307}
2308.ice-inline-form .ice-field {
2309 width: 50%;
2310 height: 40px;
2311}
2312.ice-inline-form .field-wrapper {
2313 overflow: hidden;
2314 background-color: #ddd;
2315 padding-top: 15px;
2316 padding-bottom: 15px;
2317}
2318.ice-inline-form .btn {
2319 margin-top: 20px;
2320}</style>
2321 </div>
2322 <div class="code-box">
2323 <div class="code-box-demo">
2324 <div id="layout-line-two-fields"></div>
2325 </div>
2326 <div class="markdown">
2327 <div class="highlight">
2328 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
2329<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
2330<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
2331<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input<span class="token punctuation">,</span> Switch<span class="token punctuation">,</span> Select<span class="token punctuation">,</span> Checkbox <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
2332
2333<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
2334
2335<span class="token keyword">const</span> Option <span class="token operator">=</span> Select<span class="token punctuation">.</span>Option<span class="token punctuation">;</span>
2336
2337<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
2338 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2339 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
2340 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
2341 <span class="token punctuation">}</span>
2342
2343 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2344 <span class="token keyword">return</span> <span class="token punctuation">(</span>
2345 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
2346 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
2347 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
2348 <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>ice-inline-form<span class="token punctuation">"</span></span>
2349 <span class="token punctuation">></span></span>
2350 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>个人资料<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
2351 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>field-wrapper<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
2352 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>姓名:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>username<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入姓名<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2353 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2354 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>地址:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>address<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入地址<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2355 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>手机:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>tel<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入手机号码<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2356 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>邮件:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>email<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入邮件地址<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2357 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2358
2359 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>btn<span class="token punctuation">"</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
2360 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
2361 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2362 <span class="token punctuation">)</span><span class="token punctuation">;</span>
2363 <span class="token punctuation">}</span>
2364<span class="token punctuation">}</span>
2365
2366ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
2367 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
2368<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
2369 </div>
2370 <div class="highlight">
2371 <pre><code lang="css"><span class="token selector">.ice-inline-form .field-wrapper</span> <span class="token punctuation">{</span>
2372 <span class="token property">display</span><span class="token punctuation">:</span> flex<span class="token punctuation">;</span>
2373 <span class="token property">flex-wrap</span><span class="token punctuation">:</span> wrap<span class="token punctuation">;</span>
2374<span class="token punctuation">}</span>
2375<span class="token selector">.ice-inline-form .ice-field</span> <span class="token punctuation">{</span>
2376 <span class="token property">width</span><span class="token punctuation">:</span> 50%<span class="token punctuation">;</span>
2377 <span class="token property">height</span><span class="token punctuation">:</span> 40px<span class="token punctuation">;</span>
2378<span class="token punctuation">}</span>
2379<span class="token selector">.ice-inline-form .field-wrapper</span> <span class="token punctuation">{</span>
2380 <span class="token property">overflow</span><span class="token punctuation">:</span> hidden<span class="token punctuation">;</span>
2381 <span class="token property">background-color</span><span class="token punctuation">:</span> #ddd<span class="token punctuation">;</span>
2382 <span class="token property">padding-top</span><span class="token punctuation">:</span> 15px<span class="token punctuation">;</span>
2383 <span class="token property">padding-bottom</span><span class="token punctuation">:</span> 15px<span class="token punctuation">;</span>
2384<span class="token punctuation">}</span>
2385<span class="token selector">.ice-inline-form .btn</span> <span class="token punctuation">{</span>
2386 <span class="token property">margin-top</span><span class="token punctuation">:</span> 20px<span class="token punctuation">;</span>
2387<span class="token punctuation">}</span></code></pre>
2388 </div>
2389 </div>
2390 </div>
2391 </div>
2392 <div class="preview" id="container_layout-first-line-two-fields">
2393 <h3>第一行两个 Field</h3>
2394 <div class="markdown">
2395 <style>.ice-first-inline-form .ice-field .ice-field-label {
2396 display: inline;
2397 width: auto ;
2398}</style>
2399 </div>
2400 <div class="code-box">
2401 <div class="code-box-demo">
2402 <div id="layout-first-line-two-fields"></div>
2403 </div>
2404 <div class="markdown">
2405 <div class="highlight">
2406 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
2407<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
2408<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
2409<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input<span class="token punctuation">,</span> Switch<span class="token punctuation">,</span> Select<span class="token punctuation">,</span> Checkbox <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
2410
2411<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
2412
2413<span class="token keyword">const</span> Option <span class="token operator">=</span> Select<span class="token punctuation">.</span>Option<span class="token punctuation">;</span>
2414
2415<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
2416 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2417 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
2418 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
2419 <span class="token punctuation">}</span>
2420
2421 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2422 <span class="token keyword">return</span> <span class="token punctuation">(</span>
2423 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
2424 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
2425 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
2426 <span class="token attr-name">layout</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>
2427 labelTextAlign<span class="token punctuation">:</span> <span class="token string">'left'</span>
2428 <span class="token punctuation">}</span><span class="token punctuation">}</span></span>
2429 <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>ice-first-inline-form<span class="token punctuation">"</span></span>
2430 <span class="token punctuation">></span></span>
2431 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>个人资料<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
2432 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>display<span class="token punctuation">:</span> <span class="token string">'flex'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
2433 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>flexBasis<span class="token punctuation">:</span> <span class="token string">'35%'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>姓名:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>username<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入姓名<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2434 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>flexBasis<span class="token punctuation">:</span> <span class="token string">'30%'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>年龄:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>age<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入年龄<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2435 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2436 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>地址:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>address<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入地址<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2437 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>手机:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>tel<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>number<span class="token punctuation">"</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入手机号码<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2438 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>邮件:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>email<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入邮件地址<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2439 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">style</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>marginLeft<span class="token punctuation">:</span> <span class="token string">'60px'</span><span class="token punctuation">,</span> marginTop<span class="token punctuation">:</span> <span class="token string">'15px'</span><span class="token punctuation">}</span><span class="token punctuation">}</span></span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>btn<span class="token punctuation">"</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
2440 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
2441 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2442 <span class="token punctuation">)</span><span class="token punctuation">;</span>
2443 <span class="token punctuation">}</span>
2444<span class="token punctuation">}</span>
2445
2446ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
2447 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
2448<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
2449 </div>
2450 <div class="highlight">
2451 <pre><code lang="css"><span class="token selector">.ice-first-inline-form .ice-field .ice-field-label</span> <span class="token punctuation">{</span>
2452 <span class="token property">display</span><span class="token punctuation">:</span> inline<span class="token punctuation">;</span>
2453 <span class="token property">width</span><span class="token punctuation">:</span> auto <span class="token punctuation">;</span>
2454<span class="token punctuation">}</span></code></pre>
2455 </div>
2456 </div>
2457 </div>
2458 </div>
2459 <div class="preview" id="container_field-array">
2460 <h3>FieldArray 组件</h3>
2461 <div class="markdown">
2462 <style>.field-array-item [class*='ice-col-'] {
2463 padding-top: 0;
2464 padding-left: 0;
2465}</style>
2466 </div>
2467 <div class="code-box">
2468 <div class="code-box-demo">
2469 <div id="field-array"></div>
2470 </div>
2471 <div class="markdown">
2472 <div class="highlight">
2473 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
2474<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
2475<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> FieldArray<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
2476<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input<span class="token punctuation">,</span> DatePicker <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
2477
2478<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
2479
2480<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
2481 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2482 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
2483 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
2484 <span class="token punctuation">}</span>
2485
2486 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2487 <span class="token keyword">return</span> <span class="token punctuation">(</span>
2488 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
2489 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
2490 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
2491 <span class="token punctuation">></span></span>
2492 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">></span></span>新增顾客名单<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">></span></span>
2493 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">FieldArray</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>新增顾客:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>customers<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
2494 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>field-array-item<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>customer0<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入顾客的名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2495 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>field-array-item<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>customer1<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入顾客的名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2496 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>field-array-item<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>customer2<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入顾客的名字<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2497 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">FieldArray</span></span><span class="token punctuation">></span></span>
2498 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>日期:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>date<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>DatePicker<span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
2499 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
2500 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
2501 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
2502 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
2503 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2504 <span class="token punctuation">)</span><span class="token punctuation">;</span>
2505 <span class="token punctuation">}</span>
2506<span class="token punctuation">}</span>
2507
2508ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
2509 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
2510<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
2511 </div>
2512 <div class="highlight">
2513 <pre><code lang="css"><span class="token selector">.field-array-item [class*='ice-col-']</span> <span class="token punctuation">{</span>
2514 <span class="token property">padding-top</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
2515 <span class="token property">padding-left</span><span class="token punctuation">:</span> 0<span class="token punctuation">;</span>
2516<span class="token punctuation">}</span></code></pre>
2517 </div>
2518 </div>
2519 </div>
2520 </div>
2521 <div class="preview" id="container_fusion-component">
2522 <h3>Fusion 表单组件</h3>
2523 <div class="markdown">
2524 <p>Fusion 表单组件</p>
2525
2526 </div>
2527 <div class="code-box">
2528 <div class="code-box-demo">
2529 <div id="fusion-component"></div>
2530 </div>
2531 <div class="markdown">
2532 <div class="highlight">
2533 <pre><code lang="jsx"><span class="token keyword">import</span> React<span class="token punctuation">,</span> <span class="token punctuation">{</span> Component <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'react'</span><span class="token punctuation">;</span>
2534<span class="token keyword">import</span> ReactDOM <span class="token keyword">from</span> <span class="token string">'react-dom'</span><span class="token punctuation">;</span>
2535<span class="token keyword">import</span> <span class="token punctuation">{</span> Form<span class="token punctuation">,</span> Field <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@ice/form'</span><span class="token punctuation">;</span>
2536<span class="token keyword">import</span> <span class="token punctuation">{</span> Button<span class="token punctuation">,</span> Input<span class="token punctuation">,</span> NumberPicker<span class="token punctuation">,</span> Switch<span class="token punctuation">,</span> Range<span class="token punctuation">,</span> Select<span class="token punctuation">,</span> DatePicker<span class="token punctuation">,</span> TimePicker<span class="token punctuation">,</span> Checkbox<span class="token punctuation">,</span> Radio <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@alifd/next'</span><span class="token punctuation">;</span>
2537
2538<span class="token keyword">const</span> Option <span class="token operator">=</span> Select<span class="token punctuation">.</span>Option<span class="token punctuation">;</span>
2539
2540<span class="token keyword">const</span> <span class="token function-variable function">sleep</span> <span class="token operator">=</span> <span class="token parameter">ms</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token parameter">resolve</span> <span class="token operator">=></span> <span class="token function">setTimeout</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> ms<span class="token punctuation">)</span><span class="token punctuation">)</span>
2541
2542<span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token keyword">extends</span> <span class="token class-name">Component</span> <span class="token punctuation">{</span>
2543 <span class="token keyword">async</span> <span class="token function">onSubmit</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2544 <span class="token keyword">await</span> <span class="token function">sleep</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>
2545 window<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>values<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
2546 <span class="token punctuation">}</span>
2547
2548 <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
2549 <span class="token keyword">return</span> <span class="token punctuation">(</span>
2550 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span><span class="token punctuation">></span></span>
2551 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Form</span></span>
2552 <span class="token attr-name">onSubmit</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>onSubmit<span class="token punctuation">}</span></span>
2553 <span class="token punctuation">></span></span>
2554 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Password:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>password<span class="token punctuation">"</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>password<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Input<span class="token punctuation">}</span></span> <span class="token attr-name">placeholder</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>请输入密码<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>
2555 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>NumberPicker:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>numberPicker<span class="token punctuation">"</span></span> <span class="token attr-name">defaultValue</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token number">3</span><span class="token punctuation">}</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>NumberPicker<span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
2556 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Switch:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>switch<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Switch<span class="token punctuation">}</span></span> <span class="token attr-name">valueName</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>checked<span class="token punctuation">"</span></span> <span class="token attr-name">value</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token boolean">false</span><span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
2557 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Range:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>range<span class="token punctuation">"</span></span> <span class="token attr-name">defaultValue</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token number">30</span><span class="token punctuation">}</span></span> <span class="token attr-name">scales</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span> <span class="token attr-name">marks</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Range<span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
2558 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Select:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>select<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Select<span class="token punctuation">}</span></span> <span class="token attr-name">defaultValue</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">'</span>lucy<span class="token punctuation">'</span></span><span class="token punctuation">></span></span>
2559 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>jack<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>jack<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Option</span></span><span class="token punctuation">></span></span>
2560 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>lucy<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>lucy<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Option</span></span><span class="token punctuation">></span></span>
2561 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>disabled<span class="token punctuation">"</span></span> <span class="token attr-name">disabled</span><span class="token punctuation">></span></span>disabled<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Option</span></span><span class="token punctuation">></span></span>
2562 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Option</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>hugohua<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>hugohua<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Option</span></span><span class="token punctuation">></span></span>
2563 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
2564 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>DatePicker:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>date<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>DatePicker<span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
2565 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>TimePicker:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>time<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>TimePicker<span class="token punctuation">}</span></span> <span class="token punctuation">/></span></span>
2566 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Checkbox:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>checkbox<span class="token punctuation">"</span></span> <span class="token attr-name">defaultValue</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">}</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Checkbox<span class="token punctuation">.</span>Group<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
2567 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>a<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>option <span class="token number">1</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>
2568 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>b<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>option <span class="token number">2</span> <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>
2569 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Checkbox</span></span> <span class="token attr-name">disabled</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>c<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>option <span class="token number">3</span>(disabled)<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Checkbox</span></span><span class="token punctuation">></span></span>
2570 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
2571 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Radio:<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>radio<span class="token punctuation">"</span></span> <span class="token attr-name">component</span><span class="token script language-javascript"><span class="token script-punctuation punctuation">=</span><span class="token punctuation">{</span>Radio<span class="token punctuation">.</span>Group<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>
2572 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Radio</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>apple<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>apple<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Radio</span></span><span class="token punctuation">></span></span>
2573 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Radio</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>banana<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>banana<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Radio</span></span><span class="token punctuation">></span></span>
2574 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Radio</span></span> <span class="token attr-name">disabled</span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>cherry<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>cherry(disabled)<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Radio</span></span><span class="token punctuation">></span></span>
2575 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
2576 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Field</span></span> <span class="token attr-name">label</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
2577 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">Button</span></span> <span class="token attr-name">htmlType</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>submit<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Submit<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Button</span></span><span class="token punctuation">></span></span>
2578 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Field</span></span><span class="token punctuation">></span></span>
2579 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token class-name">Form</span></span><span class="token punctuation">></span></span>
2580 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
2581 <span class="token punctuation">)</span><span class="token punctuation">;</span>
2582 <span class="token punctuation">}</span>
2583<span class="token punctuation">}</span>
2584
2585ReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">(</span>
2586 <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token class-name">App</span></span> <span class="token punctuation">/></span></span>
2587<span class="token punctuation">)</span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
2588 </div>
2589 </div>
2590 </div>
2591 </div>
2592 </div>
2593 <ul class="demo-list">
2594 <li>示例导航</li>
2595 <li><a href="#container_simple">基本用法</a></li>
2596 <li><a href="#container_reset">重置表单</a></li>
2597 <li><a href="#container_validation">基础校验</a></li>
2598 <li><a href="#container_async-validation">异步校验</a></li>
2599 <li><a href="#container_linkage">基础联动</a></li>
2600 <li><a href="#container_province-city">省市联动</a></li>
2601 <li><a href="#container_complex-linkage">复杂联动</a></li>
2602 <li><a href="#container_custom-field-layout">自定义 Field 布局</a></li>
2603 <li><a href="#container_value-formatter">格式化 Field 值</a></li>
2604 <li><a href="#container_reusable-field-groups">复用 Field 组</a></li>
2605 <li><a href="#container_loading-value">异步加载数据渲染</a></li>
2606 <li><a href="#container_dialog-form">Dialog 表单</a></li>
2607 <li><a href="#container_antd-component">结合 Antd 组件</a></li>
2608 <li><a href="#container_raw-html">原生 html 标签</a></li>
2609 <li><a href="#container_async-form-props">异步更新 Form props</a></li>
2610 <li><a href="#container_layout">表单布局</a></li>
2611 <li><a href="#container_label-layout">标签布局</a></li>
2612 <li><a href="#container_custom-label">自定义标签</a></li>
2613 <li><a href="#container_big-form">大表单</a></li>
2614 <li><a href="#container_layout-line-two-fields">一行两个 Field</a></li>
2615 <li><a href="#container_layout-first-line-two-fields">第一行两个 Field</a></li>
2616 <li><a href="#container_field-array">FieldArray 组件</a></li>
2617 <li><a href="#container_fusion-component">Fusion 表单组件</a></li>
2618 </ul>
2619 </div>
2620
2621<script type="text/javascript" src="./index.js"></script></body>
2622
2623</html>