vantUI时间选择器默认选中值为:
更改之后
代码如下
<van-popup v-model="startTimeshow" position="bottom" :overlay="true">
<van-datetime-picker
@cancel="Cancel"
@confirm="Confirm"
@change="Change"
v-model="currentDate"
type="date"
/>
</van-popup>
data() {
return {
currentDate: new Date()
};
},
methods:{
Change(){
console.log(this.currentDate);
var date = this.currentDate;
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
this.currentdate =
date.getFullYear() +
seperator1 +
month +
seperator1 +
strDate +
" " +
"00" +
seperator2 +
"00" +
seperator2 +
"00";
}
}