Skip to content

Commit 680a416

Browse files
committed
docs(ProForm): 通过useForm设置表单upload组件例子
1 parent 0c0a5e3 commit 680a416

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

packages/components/src/ProForm/README.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,10 @@ import React from 'react';
493493
import { ProForm,useForm } from '@uiw-admin/components'
494494
import { Button } from 'uiw'
495495
const Demo = () => {
496-
const [state,setState] = React.useState({})
496+
const [state,setState] = React.useState({
497+
input:'',
498+
upload: []
499+
})
497500
const form = useForm()
498501

499502
return (
@@ -507,14 +510,23 @@ const Demo = () => {
507510
label: 'input',
508511
key: 'input',
509512
widget: 'input',
510-
initialValue: '',
513+
initialValue: state.input,
511514
widgetProps: {},
512515
span:"24",
513516
required:true,
514517
rules: [
515518
{ pattern: new RegExp(/[1][3][0-9]{9}$/), message: "请输入正确手机号" },
516519
]
517520
},
521+
{
522+
label: 'upload',
523+
key: 'upload',
524+
widget: 'upload',
525+
initialValue: state.upload,
526+
widgetProps:{
527+
uploadType: 'card',
528+
},
529+
},
518530
]}
519531
/>
520532
<Button
@@ -547,8 +559,14 @@ const Demo = () => {
547559
style={{ marginTop:10,width:80 }}
548560
type="primary"
549561
onClick={()=> {
550-
form.setFields({input:'1234'})
551-
setState({input:'1234'})
562+
form.setFields({
563+
input:'1234',
564+
upload:[ { dataURL: 'https://avatars2.githubusercontent.com/u/1680273?s=40&v=4', name: 'uiw.png' }]
565+
})
566+
setState({
567+
input:'1234',
568+
upload:[ { dataURL: 'https://avatars2.githubusercontent.com/u/1680273?s=40&v=4', name: 'uiw.png' }]
569+
})
552570
} }
553571
>
554572
设置

0 commit comments

Comments
 (0)