react-beautiful-checkbox

1.0.1 • Public • Published

react-beautiful-checkbox

gras

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

安装依赖

npm i react-beautiful-checkbox -S

API 介绍

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

Package Sidebar

Install

npm i react-beautiful-checkbox

Weekly Downloads

11

Version

1.0.1

License

ISC

Unpacked Size

47.2 kB

Total Files

6

Last publish

Collaborators

  • ancf