mlinquan/vue-awesome-countdown

startCountdown() restart doesn't work

avxkim opened this issue · 4 comments

<countdown
  ref="unregisterTimer"
  :end-time="new Date().getTime() + 6000"
>
  <template v-slot:process="{ timeObj }">
    <span class="ml-3 timer">
      Request SMS once again {{ timeObj.m }}:{{
        timeObj.s
      }}
    </span>
    <b-button @click="stopCountdown">STOP</b-button>
    <b-button @click="startCountdown">START</b-button>
  </template>
  <template v-slot:finish="vac">
    <b-button
      @click="unregisterDevice"
      class="ml-3"
      variant="warning"
      >Send again</b-button
    >
  </template>
</countdown>

Then a method:

private startCountdown() {
  this.$refs.unregisterTimer.startCountdown(true)
}

Doesn't actually restart a countdown, i can pause it, then start, but restart doesn't work.

Click event unregisterDevice does not match your method startCountdown.

Click event unregisterDevice does not match your method startCountdown.

Ofcourse it doesn't, because it does different thing, not restarting the countdown.

When i click <b-button @click="startCountdown">START</b-button> it fires startCountdown() method, which doesn't restart the timer.

My error, restart must use left-time, not end-time.
Reference example: https://codepen.io/mlinquan/pen/dyyWGyN

@mlinquan thanks,help me a lot~