An open API service indexing awesome lists of open source software.

https://github.com/ofcold/countdown

Typescript Countdown component for Vue 3.
https://github.com/ofcold/countdown

Last synced: about 2 months ago
JSON representation

Typescript Countdown component for Vue 3.

Awesome Lists containing this project

README

          

# countdown
Typescript Countdown component for Vue 3.

## Basic usage

```vue


Time Remaining:{{ days }} days, {{ hours }} hours, {{ minutes }} minutes, {{ seconds }} seconds.

```

## Custom interval

```vue


New Year Countdown:{{ days }} days, {{ hours }} hours, {{ minutes }} minutes, {{ seconds }}.{{ Math.floor(milliseconds / 100) }} seconds.

import {defineComponent, ref} from 'vue'
export default defineComponent({
setup() {
const now = new Date();
const newYear = ref(new Date(now.getFullYear() + 1, 0, 1));

return {
time: newYear - now,
};
}
})

```

## Countdown on demand

```vue


Fetch again {{ totalSeconds }} seconds later
Fetch Verification Code

import {ref, defineComponent} from 'vue'
export default defineComponent({
setup() {
const counting = ref(false)
function startCountdown() {
counting = true
}
function onCountdownEnd() {
counting = false
}

return {
counting,
startCountdown,
onCountdownEnd
}
}
})

```