
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
vuejs-countdown-timer
Advanced tools
npm i vuejs-countdown-timer -S
Supported Package | Version |
---|---|
Vue | 2.5+ |
Import component
// global register at main.js
import VueCountdownTimer from 'vuejs-countdown-timer';
Vue.use(VueCountdownTimer);
Vue default template
<template>
<vue-countdown-timer
@start_callback="startCallBack('event started')"
@end_callback="endCallBack('event ended')"
:start-time="'2018-10-10 00:00:00'"
:end-time="1481450115"
:interval="1000"
:start-label="'Until start:'"
:end-label="'Until end:'"
label-position="begin"
:end-text="'Event ended!'"
:day-txt="'days'"
:hour-txt="'hours'"
:minutes-txt="'minutes'"
:seconds-txt="'seconds'">
</vue-countdown-timer>
</template>
<script >
export default {
name: 'Timer',
methods: {
startCallBack: function(x) {
console.log(x);
},
endCallBack: function(x) {
console.log(x);
},
},
};
</script>
Vue Customized template
<template>
<vue-countdown-timer
@start_callback="startCallBack('event started')"
@end_callback="endCallBack('event ended')"
:start-time="'2018-10-10 00:00:00'"
:end-time="1481450115"
:interval="1000"
:start-label="'Until start:'"
:end-label="'Until end:'"
label-position="begin"
:end-text="'Event ended!'"
:day-txt="'days'"
:hour-txt="'hours'"
:minutes-txt="'minutes'"
:seconds-txt="'seconds'">
<template slot="start-label" slot-scope="scope">
<span style="color: red" v-if="scope.props.startLabel !== '' && scope.props.tips && scope.props.labelPosition === 'begin'">{{scope.props.startLabel}}:</span>
<span style="color: blue" v-if="scope.props.endLabel !== '' && !scope.props.tips && scope.props.labelPosition === 'begin'">{{scope.props.endLabel}}:</span>
</template>
<template slot="countdown" slot-scope="scope">
<span>{{scope.props.days}}</span><i>{{scope.props.dayTxt}}</i>
<span>{{scope.props.hours}}</span><i>{{scope.props.hourTxt}}</i>
<span>{{scope.props.minutes}}</span><i>{{scope.props.minutesTxt}}</i>
<span>{{scope.props.seconds}}</span><i>{{scope.props.secondsTxt}}</i>
</template>
<template slot="end-label" slot-scope="scope">
<span style="color: red" v-if="scope.props.startLabel !== '' && scope.props.tips && scope.props.labelPosition === 'end'">{{scope.props.startLabel}}:</span>
<span style="color: blue" v-if="scope.props.endLabel !== '' && !scope.props.tips && scope.props.labelPosition === 'end'">{{scope.props.endLabel}}:</span>
</template>
<template slot="end-text" slot-scope="scope">
<span style="color: green">{{ scope.props.endText}}</span>
</template>
</vue-countdown-timer>
</template>
<script >
export default {
name: 'Timer',
methods: {
startCallBack: function(x) {
console.log(x);
},
endCallBack: function(x) {
console.log(x);
},
},
};
</script>
Slot name | Description |
---|---|
start-label | Timer start label |
countdown | Timer countdown label |
end-label | Timer end label |
end-text | Timer ended text |
start-label
Scoped SlotSlot scope name | Description |
---|---|
startLabel | Event begin label text |
endLabel | Event end label text |
tips | Tips true means countdown till start, false means countdown till end |
labelPosition | event label position, 'begin' or 'end' |
countdown
Scoped SlotSlot scope name | Description |
---|---|
days | Number of days till event |
dayTxt | Day label |
hours | Number of hours till event |
hourTxt | Hours label |
minutes | Number of minutes till event |
minuteTxt | Minutes label |
seconds | Number of seconds till event |
secondTxt | Seconds label |
showDay | display status of day countdown number and text |
showHour | display status of hour countdown number and text |
showMinute | display status of minute countdown number and text |
end-label
Scoped SlotSlot scope name | Description |
---|---|
startLabel | Event begin label text |
endLabel | Event end label text |
tips | Tips true means countdown till start, false means countdown till end |
labelPosition | event label position, 'begin' or 'end' |
end-text
Scoped SlotSlot scope name | Description |
---|---|
endText | Timer ended text |
start-time
type
: Number|Stringrequired
: trueend-time
type
: Number|Stringrequired
: trueinterval
type
: Numberrequired
: falsedefault
: 1000start-label
type
: Stringrequired
: falsedefault
: ''end-label
type
: Stringrequired
: falsedefault
: ''label-position - begin (before countdown) / end (after countdown)
type
: Stringrequired
: falsedefault
: 'begin'end-text
type
: Stringrequired
: falsedefault
: 'Event ended!'day-txt - if pass null
, this unit will be hidden
type
: Stringrequired
: falsedefault
: ':'hour-txt - if pass null
, this unit will be hidden
type
: Stringrequired
: falsedefault
: ':'seconds-txt - if pass null
, this unit will be hidden
type
: Stringrequired
: falsedefault
: ':'seconds-fixed
type
: Stringrequired
: falsedefault
: ':'show-zero - display status of 00
type
: Booleanrequired
: falsedefault
: truestart_callback - Event started callback
type
: Functionrequired
: falseend_callback - Event ended callback
type
: Functionrequired
: falseIf the end-time
prop is dynamically generated or 'computed', the initial value will be NaN
. This will trigger the end_callback
function, which might not be desirable. This can be solved by declaring it this way:
<template>
<vue-countdown-timer
...
:end-time="end_at?end_at:endAt"
...
></vue-countdown-timer>
</template>
<script>
data() {
return {
endAt: (new Date).getTime()+5000
}
}
</script>
Where end_at
is the computed value, and endAt
is a default value.
MIT License
FAQs
Vue 2 countdown and timer component
The npm package vuejs-countdown-timer receives a total of 1,583 weekly downloads. As such, vuejs-countdown-timer popularity was classified as popular.
We found that vuejs-countdown-timer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.