element-plus/docs/examples/statistic/countdown.vue
Xc 9a119d8081
feat(components): [statistic] (#11420)
* feat(components): [statistic]

* feat(components): [statistic]
2023-02-04 20:20:18 +08:00

55 lines
1.3 KiB
Vue

<template>
<el-row>
<el-col :span="8">
<el-countdown title="Start to grab" :value="value" />
</el-col>
<el-col :span="8">
<el-countdown
title="Remaining VIP time"
format="HH:mm:ss"
:value="value1"
/>
<el-button class="countdown-footer" type="primary" @click="reset"
>Reset
</el-button>
</el-col>
<el-col :span="8">
<el-countdown format="DD [days] HH:mm:ss" :value="value2">
<template #title>
<div style="display: inline-flex; align-items: center">
<el-icon style="margin-right: 4px" :size="12">
<Calendar />
</el-icon>
Still to go until next month
</div>
</template>
</el-countdown>
<div class="countdown-footer">{{ value2.format('YYYY-MM-DD') }}</div>
</el-col>
</el-row>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import dayjs from 'dayjs'
import { Calendar } from '@element-plus/icons-vue'
const value = ref(Date.now() + 1000 * 60 * 60 * 7)
const value1 = ref(Date.now() + 1000 * 60 * 60 * 24 * 2)
const value2 = ref(dayjs().add(1, 'month').startOf('month'))
function reset() {
value1.value = Date.now() + 1000 * 60 * 60 * 24 * 2
}
</script>
<style scoped>
.el-col {
text-align: center;
}
.countdown-footer {
margin-top: 8px;
}
</style>