需要实现同时选择日期和时间,并且能够方便的赋初始值
html
<el-form-item label="日期时间">
<el-date-picker v-model="form.selectDatetime" type="datetime" placeholder="选择时间"
@change="dataSearch" value-format="yyyy-MM-dd HH:mm" format="yyyy-MM-dd HH:mm"></el-date-
picker>
</el-form-item>
js
dataSearch() {
this.getListByDataTime();
},
async initData(data) {
//获取当前时间
var now = new Date();
var monthn = now.getMonth()+1;
var yearn = now.getFullYear();
var dayn = now.getDate();
var h = now.getHours();
var m =now.getMinutes();
var s = now.getSeconds();
this.form.selectDatetime = yearn+"-"+monthn+"-"+dayn+" "+h+":"+m+":"+s;
this.getListByDataTime();
},
async getListByDataTime(data) {
},
初始赋值
this.$set(this.form, 'selectDatetime', '2020-03-03 03:00');