Skip to content

Commit

Permalink
docs(FormRender): improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Barrior committed Jan 5, 2024
1 parent c948a54 commit 0309254
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions examples/form-render-react/500-builtin-renderers.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,26 @@ import * as styles from './styles'
import schema from './schemas/all'

const Demo = () => {
const [isDisabled, setIsDisabled] = useState(false)
const [isReadonly, setIsReadonly] = useState(false)
const [value, setValue] = useState<object>({
Description: '纯展示的内容吧啦吧啦',
})

const registerActions = useMemo(() => {
return {
disable: () => (
<Button type="dashed" onClick={() => setIsDisabled(!isDisabled)}>
{isDisabled ? '取消' : '设为'} disabled 状态
</Button>
),
readonly: () => (
<Button type="dashed" onClick={() => setIsReadonly(!isReadonly)}>
{isReadonly ? '取消 ' : '设置为 '}readonly 状态
{isReadonly ? '取消' : '设为'} readonly 状态
</Button>
),
}
}, [isReadonly])
}, [isReadonly, isDisabled])

return (
<div className="example-layout-cols-2">
Expand All @@ -41,8 +47,10 @@ const Demo = () => {
schema={schema}
value={value}
onChange={setValue}
actions={['submit', 'reset', 'readonly']}
actions={['submit', 'reset', 'disable', 'readonly']}
registerActions={registerActions}
// 是否禁用态
disabled={isDisabled}
// 是否只读状态
readonly={isReadonly}
// 只读状态没有数据时的占位符
Expand Down

0 comments on commit 0309254

Please sign in to comment.