倒计时
基本使用
vue
<template>
<view style="padding: 12px">
<view>
<view>演示效果</view>
<view style="display: flex; flex-wrap: wrap; justify-content: center; padding: 24rpx">
<view style="padding: 20px 40px; background-color: #f7f7f7">
<jp-countdown
color="#FFFFFF"
:splitor-color="attribute.splitorColor"
:background-color="attribute.timebackgroundColor"
border-color="#000"
:show-day="attribute.showday"
:second="attribute.second"
:show-colon="attribute.showColon"
@timeup="timeend"
></jp-countdown>
</view>
</view>
</view>
<view style="margin-top: 20px">
<view style="margin: 12px 0">
<view style="font-size: 16px">倒计时样式</view>
<jp-section-selector current="0" vibrate-short :list="['天', '时分秒', '文字时分秒']" @change="countChange"></jp-section-selector>
</view>
<view style="margin: 12px 0">
<view style="font-size: 16px">Theme</view>
<jp-section-selector current="0" vibrate-short :list="attribute.themeList" @change="countChange2"></jp-section-selector>
</view>
<view style="margin: 12px 0">
<view style="font-size: 16px">splitorColor</view>
<jp-section-selector current="0" vibrate-short :list="attribute.themeList" @change="countChange3"></jp-section-selector>
</view>
</view>
</view>
</template>
<script lang="ts" setup>
import { reactive } from 'vue'
const attribute = reactive({
showday: true,
second: 3600 * 60,
showColon: false,
themeList: ['#000', '#007AFF', '#1CBBB4'],
timebackgroundColor: '#000',
splitorColor: '#000'
})
const countChange = (index) => {
if (index === 0) {
attribute.showday = true
attribute.showColon = false
}
if (index === 1) {
attribute.showday = false
attribute.showColon = true
}
if (index === 2) {
attribute.showday = false
attribute.showColon = false
}
}
const countChange2 = (index) => {
attribute.timebackgroundColor = attribute.themeList[index]
}
const countChange3 = (index) => {
attribute.splitorColor = attribute.themeList[index]
}
const timeend = () => {}
</script>
<style scoped lang="scss"></style>
倒计时样式
类型设置值
- 天:
showday = true; showColon = false
- 时分秒:
showday = false showColon = true
- 文字时分秒:
showday = false ;showColon = false
html
<jp-countdown :second="attribute.second" showday="true" showColon="false"></jp-countdown>
主题 Theme
backgroundColor
:支持 ['#000', '#007AFF', '#1CBBB4']
splitorColor
splitorColor
:支持 ['#000', '#007AFF', '#1CBBB4']
props
属性列表:
属性名 | 类型 | 默认值 | 描述 |
---|---|---|---|
showDay | Boolean | true | 是否显示天数 |
showColon | Boolean | true | 是否显示时间分隔符冒号 |
backgroundColor | String | '#FFFFFF' | 背景颜色 |
borderColor | String | '#000000' | 边框颜色 |
color | String | '#000000' | 文字颜色 |
splitorColor | String | '#FFFFFF' | 分隔符颜色 |
day | Number | 0 | 天数 |
hour | Number | 0 | 小时数 |
minute | Number | 0 | 分钟数 |
second | Number | 0 | 秒数 |
事件列表:
事件名 | 描述 |
---|---|
timeup | 计时结束时触发的事件 |