Element: add current time to date picker
by Theara Yuom
HTML
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/[email protected]/lib/index.js"></script>
<div id="app">
<template>
<div class="block">
<span class="demonstration">Default</span>
<el-date-picker v-model="value1" type="date" placeholder="Pick a day">
</el-date-picker>
</div>
<el-button @click="getValue">Get Val</el-button>
</template>
</div>
SCSS
@import url("//unpkg.com/[email protected]/lib/theme-default/index.css");
Babel + JSX
var Main = {
data() {
return {
value1: new Date(),
dateValue:'',
};
},
watch:{
value1(v){
var d = new Date();
v.setHours(d.getHours());
v.setMinutes(d.getMinutes());
v.setSeconds(d.getSeconds());
}
},
methods:{
getValue(){
alert(this.value1);
// When change date, I get the time 00:00:00
// I would like to get date with current time all the time
}
}
};
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')