spz-countdown

When to Use

  • When you need to count down from the current time to a future time.
  • When you need to count down a specific time, for example: a 59-second countdown.
  • Start the countdown only under specific circumstances, for example: after entering the correct email, click to send the verification code, then start the countdown. You can only click to send the verification code again after the 59-second countdown is over.

Code Demonstration

Basic

A simple loop countdown.

<spz-countdown layout="container" timeleft-seconds="59" loop>
  <template>
    <div>${s}</div>
  </template>
</spz-countdown>

Manual Start

Use the restart method to manually start the countdown, and use the @timeout event to hide the countdown element when the countdown ends.

<button @tap="countdown-restart.restart;">Start countdown</button>
<spz-countdown layout="container" timeleft-seconds="59" manual id="countdown-restart" @timeout="countdown-restart.hide">
  <template>
    <div>${s}</div>
  </template>
</spz-countdown>

Properties

Property NameDescriptionTypeDefault ValueRequired
timestamp-secondsDeadline time in timestamp format, in secondsnumber-Yes, unless timeleft-seconds or end-date is configured
timeleft-secondsSpecifies the incremental time, the deadline time is the current time plus the incremental time, in secondsnumber-Yes, unless timestamp-seconds or end-date is configured
end-dateSpecifies a deadline datedataType-Yes, unless timeleft-seconds or timestamp-seconds is configured
offset-secondsSpecifies the time to continue counting down after the countdown ends, must be used in conjunction with the loop property to take effect, in secondsnumber-No
loopIf this property exists, it supports loop countdown. When the offset-seconds property is not configured, the loop is only effective when the timeleft-seconds property is configured--No
manualIf this property exists, the countdown only starts when the restart method is manually called---

Data Object Format within the Template

Property NameDescriptionTypeDefault Value
dDaysnumber0
hHoursnumber0
mMinutesnumber0
sSecondsnumber0
ddDays, two-digit numberstring00
hhHours, two-digit numberstring00
mmMinutes, two-digit numberstring00
ssSeconds, two-digit numberstring00

dataType

Supported Date Formats
YYYY/MM/DD
YYYY/MM/DD HH:mm
YYYY/MM/DD HH:mm:ss
YYYY-MM-DD
YYYY-MM-DD HH:mm
YYYY-MM-DD HH:mm:ss

Methods

restart

Restart the countdown, no parameters needed.

Events

timeout

This event is automatically triggered when the countdown ends.


AI Summary (LLM Ready)

  • Component ID: spz-countdown
  • One-line purpose: Displays a countdown by specifying a date.
  • Detected attribute rows: 0
  • Detected method subsections: 1
  • Detected event subsections: 1
  • Top attribute names: none (needs manual completion)
  • Top method names: restart
  • Top event names: timeout
  • Reading order: start from usage/examples, then verify attributes, methods, and events.
  • Related docs: /en/guide/actions-and-events/ , /en/guide/layouts/