city-casereport/miniprogram_npm/tdesign-miniprogram/count-down/README.md
2023-12-06 14:22:42 +08:00

66 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: CountDown 倒计时
description: 用于实时展示倒计时数值。
spline: data
isComponent: true
---
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-99%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-99%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-85%25-blue" /></span>
## 引入
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
```json
"usingComponents": {
"t-count-down": "tdesign-miniprogram/count-down/count-down"
}
```
## 代码演示
### 基础倒计时
{{ base }}
### 调整尺寸
{{ size }}
## API
### CountDown Props
名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
auto-start | Boolean | true | 是否自动开始倒计时 | N
content | String / Slot | 'default' | 最终倒计时的展示内容,值为'default'时使用默认的格式,否则使用自定义样式插槽 | N
format | String | HH:mm:ss | 时间格式DD-日HH-时mm-分ss-秒SSS-毫秒 | N
millisecond | Boolean | false | 是否开启毫秒级渲染 | N
size | String `v0.5.1` | 'medium' | 倒计时尺寸。可选项small/medium/large | N
split-with-unit `v0.5.1` | Boolean | false | 使用时间单位分割 | N
theme | String `v0.5.1` | 'default' | 倒计时风格。可选项default/round/square | N
time | Number | - | 必需。倒计时时长,单位毫秒 | Y
### CountDown Events
名称 | 参数 | 描述
-- | -- | --
change | `(time: TimeData)` | 时间变化时触发。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/count-down/type.ts)。<br/>`interface TimeData { days: number; hours: number; minutes: number; seconds: number; milliseconds: number }`<br/>
finish | \- | 倒计时结束时触发
### CountDown 外部样式类
类名 | 说明
-- | --
t-class | 根节点样式类
t-class-count | 计数样式类
t-class-split | 分隔线样式类
### CSS 变量
组件提供了下列 CSS 变量,可用于自定义样式。
名称 | 默认值 | 描述
-- | -- | --
--td-countdown-bg-color | @error-color-6 | -
--td-countdown-default-color | @font-gray-1 | -
--td-countdown-round-border-radius | @radius-circle | -
--td-countdown-round-color | @font-white-1 | -
--td-countdown-square-border-radius | @radius-small | -