liding
3 天以前 359f69135b571c8e7b6d046bc849655abfe7075d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<template>
  <div>
    <el-time-select
      placeholder="起始时间"
      v-model="startTime"
      :picker-options="{
      start: '00:00',
      step: '01:00',
      end: '24:00'
    }">
    </el-time-select>
    <el-time-select
      placeholder="结束时间"
      v-model="endTime"
      :picker-options="{
       start: '00:00',
      step: '01:00',
      end: '24:00',
      minTime: startTime
    }">
    </el-time-select>
  </div>
</template>
 
<script>
  export default {
    name: "index",
    data() {
      return {
        startTime: '',
        endTime: ''
      }
    },
    props: {
      value: {}
    },
    beforeMount(){
      // 接收 v-model 数据
      if(this.value){
        this.startTime = this.value.split(',')[0]
        this.endTime = this.value.split(',')[1]
      }
    },
    watch: {
      startTime: function(val) {
        this.$emit('input', [val, this.endTime].join(','))
      },
      endTime: function(val) {
        this.$emit('input', [this.startTime, val].join(','))
      }
    }
  }
</script>
 
<style scoped>
 
</style>