之前elementui都是默认00:00:00,有个别需求需要修改显示的默认值 。两种方法
第一种:1.添加picker-options 然后在data里写入
pickerOptions: {
onPick: ({ end , start}) => {
if (start) {
this.choiceDate = start.getTime()
}
if (end ) {
document.getElementsByClassName('el-date-range-picker__time-picker-wrap')[3].getElementsByClassName('el-input__inner')[0].value = '23:59:59'
this.timeDate= ''
}
},
}
2.添加@change事件,在mothod中写入
changeTimer() {
let value
if (this.creatTime) {
value = new Date(this.creatTime[1])
if (value.getHours() === 0 && value.getMinutes() === 0 && value.getSeconds() === 0) {
let year = value.getFullYear()
let month = value.getMonth()
let date = value.getDate()
this.creatTime[1] = `${year}-${month}-${date} 23:59:59`
}
}
}
最后就可以啦!
但有一个bug,就是重新选择日期时,时间还是00:00:00,点确认之后才会显示23:59:59。
第二种:直接在组件上添加default-time
修改elementui时间 默认后面的时间 x年x月x日 00:00:00 - x年x月x日 23:59:59_BUG创建者的博客-优快云博客