# CountDown
### Install
```js
import { createApp } from 'vue';
import { CountDown } from 'vant';
const app = createApp();
app.use(CountDown);
```
## Usage
### Basic Usage
```html
```
```js
import { ref } from 'vue';
export default {
setup() {
const time = ref(30 * 60 * 60 * 1000);
return { time };
},
};
```
### Custom Format
```html
```
### Millisecond
```html
```
### Custom Style
```html
{{ timeData.hours }}
:
{{ timeData.minutes }}
:
{{ timeData.seconds }}
```
### Manual Control
```html
```
```js
import { Toast } from 'vant';
export default {
setup() {
const countDown = ref(null);
const start = () => {
countDown.value.start();
};
const pause = () => {
countDown.value.pause();
};
const reset = () => {
countDown.value.reset();
};
const onFinish = () => Toast('Finished');
return {
start,
pause,
reset,
onFinish,
countDown,
};
},
};
```
## API
### Props
| Attribute | Description | Type | Default |
| --- | --- | --- | --- |
| time | Total time | _number \| string_ | `0` |
| format | Time format | _string_ | `HH:mm:ss` |
| auto-start | Whether to auto start count down | _boolean_ | `true` |
| millisecond | Whether to enable millisecond render | _boolean_ | `false` |
### Available formats
| Format | Description |
| ------ | --------------------- |
| DD | Day |
| HH | Hour |
| mm | Minute |
| ss | Second |
| S | Millisecond, 1-digit |
| SS | Millisecond, 2-digits |
| SSS | Millisecond, 3-digits |
### Events
| Event | Description | Arguments |
| ------ | -------------------------------- | -------------------------- |
| finish | Emitted when count down finished | - |
| change | Emitted when count down changed | _currentTime: CurrentTime_ |
### Slots
| Name | Description | SlotProps |
| ------- | -------------- | -------------------------- |
| default | Custom Content | _currentTime: CurrentTime_ |
### TimeData Structure
| Name | Description | Type |
| ------------ | ----------------------------- | -------- |
| total | Total time, unit milliseconds | _number_ |
| days | Remain days | _number_ |
| hours | Remain hours | _number_ |
| minutes | Remain minutes | _number_ |
| seconds | Remain seconds | _number_ |
| milliseconds | Remain milliseconds | _number_ |
### Methods
Use [ref](https://v3.vuejs.org/guide/component-template-refs.html) to get CountDown instance and call instance methods.
| Name | Description | Attribute | Return value |
| ----- | ---------------- | --------- | ------------ |
| start | Start count down | - | - |
| pause | Pause count down | - | - |
| reset | Reset count down | - | - |
### Less Variables
How to use: [Custom Theme](#/en-US/theme).
| Name | Default Value | Description |
| ----------------------- | ----------------- | ----------- |
| @count-down-text-color | `@text-color` | - |
| @count-down-font-size | `@font-size-md` | - |
| @count-down-line-height | `@line-height-md` | - |