fengyuanchen / vue-countdown

Countdown component for Vue.js.
https://fengyuanchen.github.io/vue-countdown/
MIT License
691 stars 89 forks source link

How to change the text to something else, if the countdown elapsed? #57

Closed joa77 closed 4 years ago

joa77 commented 4 years ago

How to change the text to something else instead of displaying 00:00, if the countdown elapsed?

<countdown :time="timeLeft" :transform="transform">
    <template slot-scope="props">{{ props.minutes }}:{{ props.seconds }}</template>
</countdown>
        var app = new Vue({
          el: '#app',
          data: function () {
                var now = new Date();
                return {
                    timeLeft: new Date('2020-10-15T00:05:32.000Z') - now,
                }
            },
             methods: {
                transform(props) {
                  Object.entries(props).forEach(([key, value]) => {
                    props[key] = value < 10 ? `0${value}` : value;
                  });
                  return props;
                },
              },
        })
fengyuanchen commented 4 years ago

Just follow the Fetch Verification Code demo.

In short, use v-if and v-else.