Skip to content

Commit

Permalink
fix(taro-components): 修复 onInput的e.detail.value 获取不到值 close #1439
Browse files Browse the repository at this point in the history
  • Loading branch information
jinjinjin0731 committed Dec 11, 2018
1 parent 2a38eaa commit 9eeedf7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions packages/taro-components/src/components/input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,27 @@ class Input extends Nerv.Component {
}

componentDidMount () {
this.inputRef.addEventListener('change', (e) => {
this.inputRef.addEventListener('input', (e) => {
this.onInput(e)
})
}

componentUnMount () {
this.inputRef.removeEventListener('change', (e) => {
this.inputRef.removeEventListener('input', (e) => {
this.onInput(e)
})
}

onInput (e) {
const { onInput, onChange = '' } = this.props
const { onChange = '' } = this.props
if (!this.isOnComposition) {
Object.defineProperty(e, 'detail', {
enumerable: true,
value: {
value: e.target.value
}
})
if (onChange) {
onChange && onChange(e)
} else {
onInput && onInput(e)
}
if (onChange) onChange && onChange(e)
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/src/components/picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ export default class Picker extends Nerv.Component {
} else {
eventObj.detail.value = this.index
}
eventObj.detail.value = eventObj.detail.value.join('-')
}
this.setState({
pickerValue: eventObj.detail.value
})

let reEventObj = Object.assign({}, eventObj)
reEventObj.detail.value = reEventObj.detail.value.join('-')
this.props.onChange && this.props.onChange(reEventObj)
}

Expand Down

0 comments on commit 9eeedf7

Please sign in to comment.