Skip to content

Commit

Permalink
fix(tc): checkboxGroup onChange返回值问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongxin committed Jun 11, 2018
1 parent 79e135c commit 0aaa1c4
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions packages/taro-components/src/components/checkbox/checkbox-group.js
Expand Up @@ -11,12 +11,22 @@ class CheckboxGroup extends Nerv.Component {

toggleChange (e, i) {
this.state.value[i] = {
name: e.target.value,
value: e.target.textContent,
name: e.target.textContent,
value: e.target.value,
checked: e.target.checked
}
const resp = []
this.state.value.forEach(v => {
if (v.checked) {
resp.push(v.value)
}
})
const { onChange } = this.props
onChange({ detail: { value: this.state.value } })
Object.defineProperty(e, 'detail', {
enumerable: true,
value: resp
})
onChange(e)
}

render () {
Expand All @@ -29,14 +39,14 @@ class CheckboxGroup extends Nerv.Component {
if (ch.name === 'Checkbox') {
if (ch.props.checked) {
this.state.value[i] = {
name: ch.props.value,
value: ch.props.children.props.children,
name: ch.props.name,
value: ch.props.value,
checked: true
}
} else {
this.state.value[i] = {
name: ch.props.value,
value: ch.props.children.props.children,
name: ch.props.name,
value: ch.props.value,
checked: false
}
}
Expand Down

0 comments on commit 0aaa1c4

Please sign in to comment.