1.0.1 • Published 3 years ago

react-beautiful-checkbox v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

react-beautiful-checkbox

gras

DEMO示例地址:https://kafeihaoka.github.io/react-beautiful-checkbox/

安装依赖

npm i react-beautiful-checkbox -S

API 介绍

PropertyDescriptionTypeDefault
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