< view >至</ view > < picker mode = "time" value = "{{timeEnd}}" start = "00:00" end = "24:00" bindchange = "timeEnd" >{{timeEnd}}</ picker > |
如上,实际效果如下:
我希望实现的效果:前面的时间永远早于后面的时间,所以我在第一个picker的end里面传进一个根据后面picker变化的时间。
但是,第一个picker的效果做到了,可是貌似传进的模版数据同时影响到后面picker的end了,求解~
是BUG吗?
你的局部变量名 timeEnd和data中的timeEnd重名
我按照你的改,在实机测试也行了,多谢分享。当我以为我的错误是end用了和value同一个变量时,我尝试照你的修改了下,如:
<
picker
mode
=
"time"
value
=
"{{timeStart}}"
start
=
"00:00"
end
=
"{{timeStartEnd}}"
bindchange
=
"timeStart"
>{{timeStart}}</
picker
>
<
view
>至</
view
>
<
picker
mode
=
"time"
value
=
"{{timeEnd}}"
start
=
"00:00"
end
=
"24:00"
bindchange
=
"timeEnd"
>{{timeEnd}}</
picker
>
timeStart:
function
(e) {
timeStart = e.detail.value
this
.setData({
timeStart: timeStart
})
},
timeEnd:
function
(e) {
timeEnd = e.detail.value
this
.setData({
timeEnd: timeEnd,
timeStartEnd: timeEnd
})
}
结果在实机上还是有问题,是我哪里又错了,或者说end传数据有问题呢?
<picker bindchange="startTimeEventHandler" mode="time" value="{{timeStartValue}}" start="00:00" end="24:00">{{timeStartValue}}</picker>
<view>至</view>
<picker mode="time" value="{{timeEndValue}}" start="{{timeEndStart}}" end="24:00" bindchange="endTimeEventHandler">{{timeEndValue}}</picker>
-----------------------------------------------------------------------------------------------------
data: {
timeStartValue: "00:00",
timeEndValue: "00:00",
timeEndStart: "00:00"
},
startTimeEventHandler: function (event) {
this.setData({
timeStartValue: event.detail.value,
timeEndValue: event.detail.value,
timeEndStart: event.detail.value
});
},
endTimeEventHandler: function (event) {
this.setData({
timeEndValue: event.detail.value
});
},