el-time-picker设置默认赋值时间


<template>
  <el-time-picker
    v-model="defaultTime"
    value-format="HH:mm:ss"
    @change="changeTime"
    placeholder="选择时间">
  </el-time-picker>
</template>
 
<script>
  export default {
    data() {
      return {
        defaultTime: null
      };
    }
    mounted(){
    this.initTime()
  },
  methods: {
    initTime(){
      let date = new Date()
      this.defaultTime = this.formatTime(date.getHours(), date.getMinutes(), date.getSeconds());
    },
    formatTime(hours, minutes, seconds) {
      return `${this.padStart(hours)}:${this.padStart(minutes)}:${this.padStart(seconds)}`;
    },
    padStart(value) {
      return value.toString().padStart(2, '0');
    },
    changeTime(val){
      console.log(val)
    }
  };
</script>
以上是编程学习网小编为您介绍的“el-time-picker设置默认赋值时间”的全面内容,想了解更多关于 vuejs 内容,请继续关注编程基础学习网。

本文标题为:el-time-picker设置默认赋值时间

基础教程推荐