TimePicker.vue 759 Bytes
<template>
  <el-time-picker
    v-model="timeVal"
    class="rc-time"
    type="time"
    :format="format"
    :value-format="format"
    :placeholder="placeholder"
    @change="handleInput"
  />
</template>

<script>
export default {
  name: 'RcTime',
  props: {
    placeholder: {
      type: String,
      default: '请选择时间'
    },
    format: {
      type: String,
      default: 'HH:mm:ss'
    },
    value: [String, Array]
  },
  data() {
    return {
      timeVal: this.value
    }
  },
  watch: {
    value(newVal) {
      this.timeVal = newVal
    }
  },
  methods: {
    handleInput(val) {
      this.$emit('input', val)
    }
  }
}
</script>
<style lang="stylus" scoped>
  .rc-time {
    &.el-input {
      width 202px
    }
  }
</style>