<uni-datetime-picker :isTime="false" @change="change" ref="datetimePicker" :value="value" type="daterange" end="2025-02-12"
rangeSeparator="至" />
![1***@qq.com](https://img-cdn-tc.dcloud.net.cn/account/identicon/fb9ced13117b9f371dc1ce8382d2bebe.png)
- 发布:2025-02-12 12:00
- 更新:2025-02-12 16:28
- 阅读:37
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: windows 10
HBuilderX类型: 正式
HBuilderX版本号: 4.45
第三方开发者工具版本号: 1.06.2412050 Stable
基础库版本号: 3.7.6
项目创建方式: HBuilderX
示例代码:
操作步骤:
end参数设置了2025-02-12,在选择器中选择 2025-02-04 - 2025-02-06
end参数设置了2025-02-12,在选择器中选择 2025-02-04 - 2025-02-06
预期结果:
返回的数据应为:2025-02-04 - 2025-02-06
返回的数据应为:2025-02-04 - 2025-02-06
实际结果:
实际返回的是:2025-02-12 - 2025-02-12
实际返回的是:2025-02-12 - 2025-02-12
bug描述:
uni-datetime-picker在微信小程序中使用范围选择模式,设置了end后,在ios手机上回调的日期只显示当天的,
举例:end参数设置了2025-02-12,在选择器中选择了 2025-02-04 - 2025-02-06,返回的数据是2025-02-12 - 2025-02-12
经过分析,问题出在了 uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue文件的confirmRangeChange函数中,在该函数中的if判断中,${this.tempRange.startDate} ${this.tempRange.startTime}
,尾部有空字符串,导致ios识别错误
![1***@qq.com](https://img-cdn-tc.dcloud.net.cn/account/identicon/fb9ced13117b9f371dc1ce8382d2bebe.png)
1***@qq.com (作者)
<template>
<view class="device-status">
<view class="cont-box">
<view class="date-cont-box">
<view class="date-cont position-relative" @click.stop="openDatetimePicker">
<view class="item-box">
<view class="">
<text v-if="value[0]" style="color: #000;">{{value[0]}}</text>
<text v-else>选择开始日期</text>
</view>
</view>
<view class="wire-box">
</view>
<view class="item-box">
<view class="">
<text v-if="value[1]" style="color: #000;">{{value[1]}}</text>
<text v-else>选择结束日期</text>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="example-body " style="top: -100%;position: absolute;">
<uni-datetime-picker :isTime="false" @change="change" ref="datetimePicker" :value="value" type="daterange" :end="startBefore"
rangeSeparator="至" />
</view>
</view>
</template>
<script>
export default {
data() {
return {
value: [],
startBefore: new Date().getTime(),
};
},
onReady() {},
methods: {
hourChange(e){
this.value = e;
},
}
};
</script>
<style scoped lang="scss">
.input-box{
margin-top: 16rpx;
height: 76rpx;
background: #FAFAFA;
border-radius: 4rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 18rpx;
input{
width: 500rpx;
text-align: left;
}
.text{
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: var(--h7);
color: #222222;
line-height: 40rpx;
text-align: left;
font-style: normal;
}
}
.cont-box {
// height: 204rpx;
background: #FFFFFF;
border-radius: 20rpx;
.date-cont-box{
padding: 24rpx;
}
.date-cont {
display: flex;
align-items: center;
justify-content: space-between;
.wire-box {
width: 17rpx;
height: 1rpx;
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: var(--h7);
background: #666666;
line-height: 40rpx;
text-align: left;
font-style: normal;
}
.item-box {
width: 310rpx;
height: 76rpx;
background: #FAFAFA;
border-radius: 4rpx;
display: flex;
align-items: center;
justify-content: center;
view {
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: var(--h7);
color: #AAAAAA;
line-height: 40rpx;
text-align: center;
font-style: normal;
}
image {
margin-right: 22rpx;
width: 32rpx;
height: 32rpx;
}
}
}
.btn-box {
display: flex;
align-items: center;
justify-content: center;
height: 80rpx;
background: #26A3FF;
border-radius: 0rpx 0rpx 20rpx 20rpx;
border: 2rpx solid #FFFFFF;
image {
margin-right: 8rpx;
width: 30rpx;
height: 30rpx;
}
.name {
font-family: PingFangSC, PingFang SC;
font-weight: 500;
font-size: var(--h7);
color: #FFFFFF;
line-height: 40rpx;
text-align: justify;
font-style: normal;
}
}
}
</style>
1***@qq.com (作者)
代码放到下方评论区了,使用ios设备运行到小程序就可以复现
2025-02-12 16:26
DCloud_UNI_yuhe
回复 1***@qq.com: 好,感谢反馈,我看一下
2025-02-12 16:34