直接上代码!
data() {
return {
dateTimeValue: [] //是一个数组
rentBeginTime:'',//需要给传的值 开始时间
rentEndTime: '', //结束时间
}
}
// 选择日期
dateChange(val) {
if(val) {
this.rentBeginTime = this.getCurrentTime(val[0])
this.rentEndTime = this.getCurrentTime(val[0])
}else {
this.rentBeginTime = ''
this.rentEndTime = ''
this.getList()
}
},
//处理返回的值
getCurrentTime(date) {
let Y = date.getFullYear()
let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)
let D = date.getDate() < 10 ? ('0' + date.getDate()) : date.getDate()
let hours = date.getHours() < 10 ? ('0' + date.getHours()) : date.getHours()
let minutes = date.getMinutes() < 10 ? ('0' + date.getMinutes()) : date.getMinutes()
let seconds = date.getSeconds() < 10 ? ('0' + date.getSeconds()) : date.getSeconds()
date = Y + '-' + M + '-' + D + ' ' + hours + ':' + minutes + ':' + seconds
return date
},