forked from alibaba/ice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: form-binder add valueKey (alibaba#767)
- Loading branch information
1 parent
63b1108
commit 35949c3
Showing
2 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
title: 自定义 value key 的用法 | ||
order: 4 | ||
importStyle: true | ||
--- | ||
|
||
有时候组件的取值属性不是 value,可以通过 valueKey 来进行修改 | ||
|
||
````jsx | ||
import React, { Component } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import FormBinderWrapper, { | ||
FormBinder, | ||
FormError | ||
} from '@icedesign/form-binder'; | ||
import { Checkbox } from '@icedesign/base'; | ||
|
||
class App extends Component { | ||
|
||
state = { | ||
checkbox: true, | ||
}; | ||
|
||
formChange = (state) => this.setState(state); | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<pre>{JSON.stringify(this.state, null, 2)}</pre> | ||
<FormBinderWrapper | ||
value={this.state} | ||
onChange={this.formChange} | ||
> | ||
<div> | ||
<FormBinder name="checkbox" valueKey="checked"> | ||
<Checkbox>Hello</Checkbox> | ||
</FormBinder> | ||
</div> | ||
</FormBinderWrapper> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
ReactDOM.render(<App />, mountNode); | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters