Skip to content
目录

倒计时

基本使用

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

属性列表:

属性名类型默认值描述
showDayBooleantrue是否显示天数
showColonBooleantrue是否显示时间分隔符冒号
backgroundColorString'#FFFFFF'背景颜色
borderColorString'#000000'边框颜色
colorString'#000000'文字颜色
splitorColorString'#FFFFFF'分隔符颜色
dayNumber0天数
hourNumber0小时数
minuteNumber0分钟数
secondNumber0秒数

事件列表:

事件名描述
timeup计时结束时触发的事件

©2022 By 绝配移动端组件库