react-native DatePicker --- 'react-native-datepicker' 小坑

经常需要二级联动的日期上面, DatePicker在模拟器和真机上面有一点小差别,
我们经常需要 截止时间不小于开始时间,在模拟器上,
开始时间

结束时间,但是结束时间可以比开始时间提前一天!

在真机上测试时,就是正常的。
<DatePicker
style={{ pTd(130)}}
date={this.state.createTimeStart}
mode="date"
placeholder="生产日期"
format="YYYY-MM-DD"
minDate="2016-05-01"
maxDate="2040-06-01"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
customStyles={{
dateIcon: {
display: 'none'
},
dateInput: {
height: pTd(32),
// marginLeft: 36
}
// ... You can check the source to find the other keys.
}}
onDateChange={(date) => {
this.setState({
createTimeStart: date,
createTimeEnd: date
})
}}
/>

<DatePicker
style={{ pTd(130)}}
date={this.state.createTimeEnd}
mode="date"
placeholder="生产日期"
format="YYYY-MM-DD"
minDate={this.state.createTimeStart == "" ? "2016-05-01" : this.state.createTimeStart}
maxDate="2040-06-01"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
customStyles={{
dateIcon: {
display: 'none'
},
dateInput: {
height: pTd(32),
// marginLeft: 36
}
// ... You can check the source to find the other keys.
}}
onDateChange={(date) => {
this.setState({
createTimeEnd: date,
createTimeStart: this.state.createTimeStart == "" ? date : this.state.createTimeStart
})
}}
/>

原文地址:https://www.cnblogs.com/xk-g/p/9593077.html