picker-view-column 赋值后 切换页面onShow后会被初始化2次
onShow: function () {
console.log(‘onShow’);
var that=this;
var date = new Date();
var hour = date.getHours();
var minute = date.getMinutes();
var hourPicker = hour + 1;
var minutePicker = parseInt(minute / 5) + 1;
if (hourPicker > 23) {
hourPicker = 23;
}
if (minutePicker > 11) {
minutePicker = 11;
}
that.setData({
TimePickerValue: [0, hourPicker, minutePicker],
})
},
首次打开该界面正常,第2次打开,会被赋值为[0, hourPicker, minutePicker],然后再初始化为[0, 0, 0], 不知道是什么问题?为什么还是被初始化成[0, 0, 0]