vue-datepicker-local icon indicating copy to clipboard operation
vue-datepicker-local copied to clipboard

format="YYYY-MM-DD HH:mm",日历时分选择框不能显示

Open sunchens opened this issue 5 years ago • 3 comments

image 只想年月日时分,然后就出现下面的不能选择时分,

sunchens avatar Mar 23 '20 08:03 sunchens

+1

webarthur avatar May 14 '20 19:05 webarthur

The issue is located at src/VueDatepickerLocalCalendar.vue:44

  <div :class="`${pre}-foot`" v-if="m==='H'">
    <div :class="`${pre}-hour`">
      <a :title="local.hourTip" @click="showHours=!showHours,showMinutes=showSeconds=false" :class="{on:showHours}">{{hour|dd}}</a>
      <span>:</span>
      <a :title="local.minuteTip" @click="showMinutes=!showMinutes,showHours=showSeconds=false" :class="{on:showMinutes}">{{minute|dd}}</a>
      <span>:</span>
      <a :title="local.secondTip" @click="showSeconds=!showSeconds,showHours=showMinutes=false" :class="{on:showSeconds}">{{second|dd}}</a>
    </div>

And here:

  mounted () {
    const $this = this
    const is = c => $this.format.indexOf(c) !== -1
    if (is('s') && is('m') && (is('h') || is('H'))) {
      $this.m = 'H'
    } else if (is('D')) {
      $this.m = 'D'
    } else if (is('M')) {
      $this.m = 'M'
      $this.showMonths = true
    } else if (is('Y')) {
      $this.m = 'Y'
      $this.showYears = true
    }
  }

webarthur avatar May 14 '20 20:05 webarthur

It could be something like:

  <div :class="`${pre}-foot`" v-if="m==='H'">
    <div :class="`${pre}-hour`">
      <a v-if="is('h') || is('H')" :title="local.hourTip" @click="showHours=!showHours,showMinutes=showSeconds=false" :class="{on:showHours}">{{hour|dd}}</a>
      <span v-if="(is('h') || is('H')) && is('m')">:</span>
      <a v-if="is('m')" :title="local.minuteTip" @click="showMinutes=!showMinutes,showHours=showSeconds=false" :class="{on:showMinutes}">{{minute|dd}}</a>
      <span v-if="is('m') && is('s')">:</span>
      <a v-if="is('s')" :title="local.secondTip" @click="showSeconds=!showSeconds,showHours=showMinutes=false" :class="{on:showSeconds}">{{second|dd}}</a>
    </div>

And here:

  mounted () {
    const $this = this
    const is = c => $this.format.indexOf(c) !== -1
    if (is('s') || is('m') || is('h') || is('H')) {
      $this.m = 'H'
    } else if (is('D')) {
      $this.m = 'D'
    } else if (is('M')) {
      $this.m = 'M'
      $this.showMonths = true
    } else if (is('Y')) {
      $this.m = 'Y'
      $this.showYears = true
    }
  }

webarthur avatar May 14 '20 20:05 webarthur