<view class=“tr”>
<view class=“tdText”>计划发车时间:</view>
<view class=“tdInput”>
<picker mode=“multiSelector” disabled="{{!haveCode}}" value="{{planStartTime}}" bindchange=“changeDateTime1” bindcolumnchange=“changeDateTimeColumn1” range="{{dateTimeArray1}}">
<view class=“tui-picker-detail”>
{{dateTimeArray1[0][planStartTime[0]]}}-{{dateTimeArray1[1][planStartTime[1]]}}-{{dateTimeArray1[2][planStartTime[2]]}} {{dateTimeArray1[3][planStartTime[3]]}}:{{dateTimeArray1[4][planStartTime[4]]}}
</view>
</picker>
</view>
</view>
<view class=“tr”>
<view class=“tdText”>计划到达时间:</view>
<view class=“tdInput”>
<picker mode=“multiSelector” disabled="{{!haveCode}}" value="{{planEndTime}}" bindchange=“planEndTime” bindcolumnchange=“planEndTimeColumn1” range="{{dateTimeArray1}}">
<view class=“tui-picker-detail”>
{{dateTimeArray1[0][planEndTime[0]]}}-{{dateTimeArray1[1][planEndTime[1]]}}-{{dateTimeArray1[2][planEndTime[2]]}} {{dateTimeArray1[3][planEndTime[3]]}}:{{dateTimeArray1[4][planEndTime[4]]}}
</view>
</picker>
</view>
</view>
这是页面代码,
//计划发车时间 选择时候触发
changeDateTimeColumn1(e) {
var arr = this.data.planStartTime, dateArr = this.data.dateTimeArray1;
arr[e.detail.column] = e.detail.value;
dateArr[2] = dateTimePicker.getMonthDay(dateArr[0][arr[0]], dateArr[1][arr[1]]);
var beginTime = this.data.dateTimeArray1[0][arr[0]] + “-” + this.data.dateTimeArray1[1][arr[1]] + “-” + this.data.dateTimeArray1[2][arr[2]] + " " + this.data.dateTimeArray1[3][arr[3]] + “:” + this.data.dateTimeArray1[4][arr[4]];
var planBeginTime = new Date(Date.parse(beginTime))
var t = new Date();
if (t > planBeginTime) {
wx.showToast({
title: ‘计划开始时间不能小于当前时间’,
icon: ‘none’,
duration: 2000
})
return;
}
this.setData({
dateTimeArray1: dateArr,
planStartTime: arr
});
},
planStartTime是在这个函数里面修改的,
//计划结束时间 选择时候触发
planEndTimeColumn1(e) {
var arr = this.data.planEndTime, dateArr = this.data.dateTimeArray1;
var arr1 = this.data.planStartTime;//在这里获取,
console.log(arr)
console.log(arr1)
for (var i = 0; i < arr.length ; i++){
if (arr[i] < arr1[i]){
wx.showToast({
title: ‘计划到达时间不得小于计划发车时间’,
icon: ‘none’,
duration: 2000
})
return;
}
}
}
为什么在后面这个函数里面planStartTime也会被修改,我只是获取数据而已
代码太乱没看,估摸着是数据拷贝问题,深拷贝试试
请使用代码片段提供可复现问题的代码
https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html