-
Created By ancf - (博客地址)[https://kafeihaoka.github.io/myBlog.html#/welcome]
-
react-beautiful-checkbox 为一款基于react实现的多选框组件。
DEMO示例地址:https://kafeihaoka.github.io/react-beautiful-checkbox/
npm i react-beautiful-checkbox -S
Property | Description | Type | Default |
---|---|---|---|
options | 数据列表 | array | [] |
defaultValue | 当前选中项 | array | [] |
onChange | 点击事件 | function(e){} | - |
import Checkbox from "react-beautiful-checkbox";
class RadioDemo extends React.Component {
state = {
tabValue : [],
data: [{
value: 'apple',
label: '苹果',
},{
value: 'banana',
label: '香蕉',
},{
value: 'pear',
label: '梨',
}]
};
handleChange = (e) => {
this.setState({
tabValue: e
})
}
render() {
const { data, tabValue } = this.state;
return (
<div>
<Checkbox
options={data}
defaultValue={tabValue}
onChange={this.handleChange} />
</div>
);
}
}
ReactDOM.render(<RadioDemo />, mountNode);
- react component checkbox react-beautiful-checkbox