/*! For license information please see 5395.d50f37e0.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["5395"],{66440:function(s,n,a){"use strict";a.r(n);var t=a("80681");let l=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'

CountDown \u5012\u8BA1\u65F6

\n

\u4ECB\u7ECD

\n

\u7528\u4E8E\u5B9E\u65F6\u5C55\u793A\u5012\u8BA1\u65F6\u6570\u503C\uFF0C\u652F\u6301\u6BEB\u79D2\u7CBE\u5EA6\u3002

\n

\u5F15\u5165

\n

\u901A\u8FC7\u4EE5\u4E0B\u65B9\u5F0F\u6765\u5168\u5C40\u6CE8\u518C\u7EC4\u4EF6\uFF0C\u66F4\u591A\u6CE8\u518C\u65B9\u5F0F\u8BF7\u53C2\u8003\u7EC4\u4EF6\u6CE8\u518C\u3002

\n
import { createApp } from 'vue';\nimport { CountDown } from 'vant';\n\nconst app = createApp();\napp.use(CountDown);\n
\n

\u4EE3\u7801\u6F14\u793A

\n

\u57FA\u7840\u7528\u6CD5

\n

time \u5C5E\u6027\u8868\u793A\u5012\u8BA1\u65F6\u603B\u65F6\u957F\uFF0C\u5355\u4F4D\u4E3A\u6BEB\u79D2\u3002

\n
<van-count-down :time="time" />\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const time = ref(30 * 60 * 60 * 1000);\n    return { time };\n  },\n};\n
\n

\u81EA\u5B9A\u4E49\u683C\u5F0F

\n

\u901A\u8FC7 format \u5C5E\u6027\u8BBE\u7F6E\u5012\u8BA1\u65F6\u6587\u672C\u7684\u5185\u5BB9\u3002

\n
<van-count-down :time="time" format="DD \u5929 HH \u65F6 mm \u5206 ss \u79D2" />\n
\n

\u6BEB\u79D2\u7EA7\u6E32\u67D3

\n

\u5012\u8BA1\u65F6\u9ED8\u8BA4\u6BCF\u79D2\u6E32\u67D3\u4E00\u6B21\uFF0C\u8BBE\u7F6E millisecond \u5C5E\u6027\u53EF\u4EE5\u5F00\u542F\u6BEB\u79D2\u7EA7\u6E32\u67D3\u3002

\n
<van-count-down millisecond :time="time" format="HH:mm:ss:SS" />\n
\n

\u81EA\u5B9A\u4E49\u6837\u5F0F

\n

\u901A\u8FC7\u63D2\u69FD\u81EA\u5B9A\u4E49\u5012\u8BA1\u65F6\u7684\u6837\u5F0F\uFF0CtimeData \u5BF9\u8C61\u683C\u5F0F\u89C1\u4E0B\u65B9\u8868\u683C\u3002

\n
<van-count-down :time="time">\n  <template #default="timeData">\n    <span class="block">{{ timeData.hours }}</span>\n    <span class="colon">:</span>\n    <span class="block">{{ timeData.minutes }}</span>\n    <span class="colon">:</span>\n    <span class="block">{{ timeData.seconds }}</span>\n  </template>\n</van-count-down>\n\n<style>\n  .colon {\n    display: inline-block;\n    margin: 0 4px;\n    color: #1989fa;\n  }\n  .block {\n    display: inline-block;\n    width: 22px;\n    color: #fff;\n    font-size: 12px;\n    text-align: center;\n    background-color: #1989fa;\n  }\n</style>\n
\n

\u624B\u52A8\u63A7\u5236

\n

\u901A\u8FC7 ref \u83B7\u53D6\u5230\u7EC4\u4EF6\u5B9E\u4F8B\u540E\uFF0C\u53EF\u4EE5\u8C03\u7528 start\u3001pause\u3001reset \u65B9\u6CD5\u3002

\n
<van-count-down\n  ref="countDown"\n  millisecond\n  :time="3000"\n  :auto-start="false"\n  format="ss:SSS"\n  @finish="onFinish"\n/>\n<van-grid clickable>\n  <van-grid-item text="\u5F00\u59CB" icon="play-circle-o" @click="start" />\n  <van-grid-item text="\u6682\u505C" icon="pause-circle-o" @click="pause" />\n  <van-grid-item text="\u91CD\u7F6E" icon="replay" @click="reset" />\n</van-grid>\n
\n
import { showToast } from 'vant';\n\nexport default {\n  setup() {\n    const countDown = ref(null);\n\n    const start = () => {\n      countDown.value.start();\n    };\n    const pause = () => {\n      countDown.value.pause();\n    };\n    const reset = () => {\n      countDown.value.reset();\n    };\n    const onFinish = () => showToast('\u5012\u8BA1\u65F6\u7ED3\u675F');\n\n    return {\n      start,\n      pause,\n      reset,\n      onFinish,\n      countDown,\n    };\n  },\n};\n
\n

API

\n

Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53C2\u6570\u8BF4\u660E\u7C7B\u578B\u9ED8\u8BA4\u503C
time\u5012\u8BA1\u65F6\u65F6\u957F\uFF0C\u5355\u4F4D\u6BEB\u79D2number | string0
format\u65F6\u95F4\u683C\u5F0FstringHH:mm:ss
auto-start\u662F\u5426\u81EA\u52A8\u5F00\u59CB\u5012\u8BA1\u65F6booleantrue
millisecond\u662F\u5426\u5F00\u542F\u6BEB\u79D2\u7EA7\u6E32\u67D3booleanfalse
\n

format \u683C\u5F0F

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u683C\u5F0F\u8BF4\u660E
DD\u5929\u6570
HH\u5C0F\u65F6
mm\u5206\u949F
ss\u79D2\u6570
S\u6BEB\u79D2\uFF081 \u4F4D\uFF09
SS\u6BEB\u79D2\uFF082 \u4F4D\uFF09
SSS\u6BEB\u79D2\uFF083 \u4F4D\uFF09
\n

Events

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u4E8B\u4EF6\u540D\u8BF4\u660E\u56DE\u8C03\u53C2\u6570
finish\u5012\u8BA1\u65F6\u7ED3\u675F\u65F6\u89E6\u53D1-
change\u5012\u8BA1\u65F6\u53D8\u5316\u65F6\u89E6\u53D1currentTime: CurrentTime
\n

Slots

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u8BF4\u660E\u53C2\u6570
default\u81EA\u5B9A\u4E49\u5185\u5BB9currentTime: CurrentTime
\n

CurrentTime \u683C\u5F0F

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u8BF4\u660E\u7C7B\u578B
total\u5269\u4F59\u603B\u65F6\u95F4\uFF08\u5355\u4F4D\u6BEB\u79D2\uFF09number
days\u5269\u4F59\u5929\u6570number
hours\u5269\u4F59\u5C0F\u65F6number
minutes\u5269\u4F59\u5206\u949Fnumber
seconds\u5269\u4F59\u79D2\u6570number
milliseconds\u5269\u4F59\u6BEB\u79D2number
\n

\u65B9\u6CD5

\n

\u901A\u8FC7 ref \u53EF\u4EE5\u83B7\u53D6\u5230 CountDown \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\uFF0C\u8BE6\u89C1\u7EC4\u4EF6\u5B9E\u4F8B\u65B9\u6CD5\u3002

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u65B9\u6CD5\u540D\u8BF4\u660E\u53C2\u6570\u8FD4\u56DE\u503C
start\u5F00\u59CB\u5012\u8BA1\u65F6--
pause\u6682\u505C\u5012\u8BA1\u65F6--
reset\u91CD\u8BBE\u5012\u8BA1\u65F6\uFF0C\u82E5 auto-start \u4E3A true\uFF0C\u91CD\u8BBE\u540E\u4F1A\u81EA\u52A8\u5F00\u59CB\u5012\u8BA1\u65F6--
\n

\u7C7B\u578B\u5B9A\u4E49

\n

\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A

\n
import type {\n  CountDownProps,\n  CountDownInstance,\n  CountDownCurrentTime,\n} from 'vant';\n
\n

CountDownInstance \u662F\u7EC4\u4EF6\u5B9E\u4F8B\u7684\u7C7B\u578B\uFF0C\u7528\u6CD5\u5982\u4E0B\uFF1A

\n
import { ref } from 'vue';\nimport type { CountDownInstance } from 'vant';\n\nconst countDownRef = ref<CountDownInstance>();\n\ncountDownRef.value?.start();\n
\n

\u4E3B\u9898\u5B9A\u5236

\n

\u6837\u5F0F\u53D8\u91CF

\n

\u7EC4\u4EF6\u63D0\u4F9B\u4E86\u4E0B\u5217 CSS \u53D8\u91CF\uFF0C\u53EF\u7528\u4E8E\u81EA\u5B9A\u4E49\u6837\u5F0F\uFF0C\u4F7F\u7528\u65B9\u6CD5\u8BF7\u53C2\u8003 ConfigProvider \u7EC4\u4EF6\u3002

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u9ED8\u8BA4\u503C\u63CF\u8FF0
--van-count-down-text-colorvar(--van-text-color)-
--van-count-down-font-sizevar(--van-font-size-md)-
--van-count-down-line-heightvar(--van-line-height-md)-
\n

\u5E38\u89C1\u95EE\u9898

\n

\u5728 iOS \u7CFB\u7EDF\u4E0A\u5012\u8BA1\u65F6\u4E0D\u751F\u6548\uFF1F

\n

\u5982\u679C\u4F60\u9047\u5230\u4E86\u5728 iOS \u4E0A\u5012\u8BA1\u65F6\u4E0D\u751F\u6548\u7684\u95EE\u9898\uFF0C\u8BF7\u786E\u8BA4\u5728\u521B\u5EFA Date \u5BF9\u8C61\u65F6\u6CA1\u6709\u4F7F\u7528new Date(\'2020-01-01\')\u8FD9\u6837\u7684\u5199\u6CD5\uFF0CiOS \u4E0D\u652F\u6301\u4EE5\u4E2D\u5212\u7EBF\u5206\u9694\u7684\u65E5\u671F\u683C\u5F0F\uFF0C\u6B63\u786E\u5199\u6CD5\u662Fnew Date(\'2020/01/01\')\u3002

\n

\u5BF9\u6B64\u95EE\u9898\u7684\u8BE6\u7EC6\u89E3\u91CA\uFF1Astackoverflow\u3002

\n
'},null,8,l))}}}]);