forked from nsjcy/frontEnd/nsjcy

Mr Ke
2020-05-27 91294e385f43628543ebcd9ef4b9931beaabf4a1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from 'react';
import './index.less';
 
class Checkbox extends React.PureComponent {
  static defaultProps = {
    value: '',
    name: ''
  };
 
  handleChange = e => {
    const { onChange, index } = this.props;
    if (onChange) {
      onChange(e, index);
    }
  };
 
  render() {
    const {
      defaultChecked,
      value,
      name,
      index,
      label,
      style,
      disabled
    } = this.props;
    return (
      <label className="wowjoy-checkbox" style={style}>
        <input
          disabled={disabled || false}
          type="checkbox"
          name={name}
          value={value}
          data-index={index}
          defaultChecked={defaultChecked}
          onChange={this.handleChange}
          style={{ display: 'none' }}
        />
        <span className="wowjoy-checkbox__inner"></span>
        <span className="wowjoy-checkbox__text">{label}</span>
      </label>
    );
  }
}
 
export default Checkbox;