Skip to content

Commit

Permalink
fix(taro-components): 修复Taro的Picker组件的输入输出行为和微信小程序的不一致 close #1281
Browse files Browse the repository at this point in the history
  • Loading branch information
jinjinjin0731 committed Dec 3, 2018
1 parent 069fd22 commit ac77c87
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
17 changes: 9 additions & 8 deletions packages/taro-components/src/components/picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ export default class Picker extends Nerv.Component {
_value.getDate()
]
}
this.setState({
dateMaxDay: this.getDateRange(1, maxDay, '日')
})

this._dateMaxDay = this.getDateRange(1, maxDay, '日')
} else {
throw new Error('Date Interval Error')
}
Expand Down Expand Up @@ -260,7 +259,10 @@ export default class Picker extends Nerv.Component {
this.setState({
pickerValue: eventObj.detail.value
})
this.props.onChange && this.props.onChange(eventObj)

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

// 点击取消或蒙层
Expand Down Expand Up @@ -475,9 +477,8 @@ export default class Picker extends Nerv.Component {
if (max < this.pickerDate._updateValue[2]) {
this.state.height[2] = TOP - LINE_HEIGHT * max + 34
}
this.setState({
dateMaxDay: this.getDateRange(1, max, '日')
})

this._dateMaxDay = this.getDateRange(1, max, '日')
}

const gitDateSelector = () => {
Expand Down Expand Up @@ -539,7 +540,7 @@ export default class Picker extends Nerv.Component {
/>,
<PickerGroup
mode='date'
range={this.state.dateMaxDay}
range={this._dateMaxDay}
updateDay={updateDay}
height={this.state.height[2]}
updateHeight={updateHeight}
Expand Down
6 changes: 3 additions & 3 deletions packages/taro-components/src/components/swiper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let INSTANCE_ID = 0
class SwiperItem extends Nerv.Component {
render () {
const cls = classNames('swiper-slide', this.props.className)
return <div className={cls} item-id={this.props.itemId}>{this.props.children}</div>
return <div className={cls} style={this.props.style} item-id={this.props.itemId}>{this.props.children}</div>
}
}

Expand Down Expand Up @@ -95,12 +95,12 @@ class Swiper extends Nerv.Component {
}

render () {
const { className, indicatorColor, indicatorActiveColor } = this.props
const { className, style, indicatorColor, indicatorActiveColor } = this.props
let defaultIndicatorColor = indicatorColor || 'rgba(0, 0, 0, .3)'
let defaultIndicatorActiveColor = indicatorActiveColor || '#000'
const cls = classNames(`taro-swiper-${this._id}`, 'swiper-container', className)
return (
<div className={cls} ref={(el) => { this.$el = el }}>
<div className={cls} style={style} ref={(el) => { this.$el = el }}>
<div
dangerouslySetInnerHTML={{
__html: `<style type='text/css'>
Expand Down

0 comments on commit ac77c87

Please sign in to comment.