fix bugs
parent
62f6b3d2cc
commit
a872269086
@ -0,0 +1,44 @@
|
||||
import React from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import './RadioList.css'
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} props { label : [String], value : [String] }
|
||||
*/
|
||||
|
||||
class RadioList extends React.Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
this.state = { curVal: props.curVal }
|
||||
}
|
||||
|
||||
handleChange (e) {
|
||||
this.setState({ curVal: e.target.value === 'true' })
|
||||
this.props.onChange(e.target.value)
|
||||
}
|
||||
|
||||
render () {
|
||||
let that = this
|
||||
return (
|
||||
<div className='ctl-radio-list'>
|
||||
{
|
||||
this.props.data.map(item =>
|
||||
<label className='label' key={item.value}>
|
||||
<input className='input'type='radio' name={that.props.name} value={item.value}
|
||||
checked={this.state.curVal === item.value} onChange={e => that.handleChange(e)} />
|
||||
{item.label}
|
||||
</label>)
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => ({})
|
||||
const mapDispatchToProps = ({})
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(RadioList)
|
@ -0,0 +1,6 @@
|
||||
.ctl-radio-list
|
||||
line-height: 32px
|
||||
|
||||
.label
|
||||
.input
|
||||
margin: 0 6px 0 3px
|
@ -0,0 +1,10 @@
|
||||
const CONST = {
|
||||
FORM: {
|
||||
RADIO_LIST_DATA_VISIBILITY: [
|
||||
{ 'label': '私有', 'value': false },
|
||||
{ 'label': '公开', 'value': true }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CONST
|
Loading…
Reference in New Issue