vue el-date-picker 默认日期为当天
vue
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
项目地址:https://gitcode.com/gh_mirrors/vu/vue

·
page
<el-form-item>
<el-date-picker
:size="size"
v-model="dataTime"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetimerange"
@change="handleChangeDate"
range-separator="~"
start-placeholder="订单开始时间"
end-placeholder="订单结束时间"
>
</el-date-picker>
</el-form-item>
js
data () {
dataTime: '',
filters: { //查询条件
orderTimeStart: '',
orderTimeEnd: '',
},
}
// 默认 当日
getTestTime () {
let isDate = new Date()
let sTime = `${isDate.getFullYear()}-${isDate.getMonth() + 1}-${isDate.getDate()}`
let eTime = `${isDate.getFullYear()}-${isDate.getMonth() + 1}-${isDate.getDate()}`
sTime = `${sTime} 00:00:00`
eTime = `${eTime} 23:59:59`
this.dataTime = [new Date(sTime), new Date(eTime)] // 显示的默认时间
this.filters.orderTimeStart = sTime //查询 赋值
this.filters.orderTimeEnd = eTime
},
// 改变时间
handleChangeDate (e) {
if (e) {
this.filters.orderTimeStart = e[0]
this.filters.orderTimeEnd = e[1]
} else {
this.filters.orderTimeStart = ''
this.filters.orderTimeEnd = ''
}
},
mounted () {
this.getTestTime() //先调用默认时间
this.findPage(null) //在调页面查询 此方法省略
}




vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:6 个月前 )
9e887079
[skip ci] 4 个月前
73486cb5
* chore: fix link broken
Signed-off-by: snoppy <michaleli@foxmail.com>
* Update packages/template-compiler/README.md [skip ci]
---------
Signed-off-by: snoppy <michaleli@foxmail.com>
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 8 个月前
更多推荐
所有评论(0)