index.jsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import React from 'react';
  2. /*import PropTypes from 'prop-types';*/
  3. import on from '@common/images/checked.png';
  4. import style from './index.less';
  5. /**
  6. * 多选按钮
  7. * handleClick:点击触发按键 会将输入的props信息作为参数传入
  8. * isSelect:是否选中
  9. * label:右侧显示文字
  10. */
  11. class CheckBtn extends React.Component {
  12. constructor(props){
  13. super(props);
  14. this.handleClick = this.handleClick.bind(this);
  15. }
  16. handleClick(id){
  17. const {handleClick} = this.props;
  18. handleClick&&handleClick(id);
  19. }
  20. getStyle(){
  21. if(this.props.display=='block'){
  22. return {
  23. display:'block',
  24. // marginBottom:'10px'
  25. }
  26. }
  27. return {
  28. display:'inline-block',
  29. /*marginLeft:'10px'*/
  30. }
  31. }
  32. render() {
  33. const {id,label,isSelect,disabled} = this.props;
  34. /*if(disabled){
  35. return (
  36. <div className={style['check-box']}
  37. style={this.getStyle()}>
  38. <span className={style['img']}></span>
  39. <span style={{color:'#aaa'}}>{label}</span>
  40. </div>
  41. )
  42. }*/
  43. return (
  44. <div className={style['check-box']}
  45. onClick={() =>this.handleClick(id)}
  46. style={this.getStyle()}>
  47. <span className={isSelect?style['on']:style['img']}></span>
  48. <span>{label}</span>
  49. </div>
  50. )
  51. }
  52. }
  53. /*Radio.propTypes = {
  54. handleClick:PropTypes.func,
  55. isSelect:PropTypes.bool,
  56. name:PropTypes.string
  57. };*/
  58. export default CheckBtn;