如下所示:
{{pickerValue}}
formatDate(date) {
const y = date.getFullYear()
let m = date.getMonth() + 1
m = m < 10 ? '0' + m : m
let d = date.getDate()
d = d < 10 ? ('0' + d) : d
return y + ' ' + m + ' ' + d
},handleConfirm(){
let a = this.pickerValue
// console.log(a.split(" ")) ;
this.zheng=this.formatDate(this.$refs.picker.value)
console.log(this.formatDate(this.$refs.picker.value))
// console.log(this.value) ;
},设置当前日期为初始日期
<mt-datetime-picker :startDate="startDate"
data(){
return{
startDate: new Date(),}
}
设置默认值
this.zheng=new Date().getFullYear()+'年'+new Date().getMonth()+1+'月'+new Date().getDate()+'日'