UNPKG

react-admin-lte

Version:

简单封装的 AdminLTE react 类库,并包含一个编译配置。

38 lines (35 loc) 1.01 kB
import React from 'react'; import InputBase from './InputBase'; export default class InputRadio extends React.Component { constructor(props, context) { super(props, context); this.onChange = this.onChange.bind(this); } onChange(e) { if (this.props.onValueChange) { this.props.onValueChange(this.props.name, e.target.value); } if (this.props.onChange) { this.props.onChange(e); } } render() { var _this = this; return <InputBase label={this.props.label} name={this.props.name}> { this.props.options.map(function (ele, idx) { return ( <div className="radio-inline" key={idx}> <label> <input name={_this.props.name} type="radio" value={ele.value} defaultChecked={ele.value == _this.props.value} onClick={_this.onChange} /> {ele.label} </label> </div> ); }) } </InputBase>; } }