更新记录
1.0.3(2025-05-06) 下载此版本
优化组件
1.0.2(2024-11-25) 下载此版本
修复文挡 发现默认插糟在快手上不生效修改为具名插糟,查看使用说明
1.0.1(2024-08-15) 下载此版本
被全依赖项,无需再手去下载hbxw-utils依赖
查看更多平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | √ | √ | - | - | - | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
√ | - | √ | - | √ | - | - | √ | - | - | - |
hbxw-count-down组件
介绍
自定义(天小时分钟秒毫秒)倒计时组件
使用示例
推荐先直接复制示例代码到工程中看效果了解下使用方法再投入项目使用。
复制代码
<template>
<view class="container">
<text class="title">基础使用</text>
<hbxw-count-down
start="2024/7/17 20:24:00"
end="2024/7/17 21:24:00"
@count="countDownFn"
/>
<hbxw-count-down start="2024/7/17 20:24:00" end="2024/7/17 21:24:00" :delimiter="['天','小时','分钟','秒']" />
<hbxw-count-down
start="2024/7/17 20:24:00"
end="2024/7/17 21:24:00"
:delimiter="['天','小时','分钟','秒', '']"
:commonStyle="{color: 'red',fontSize: '20px'}"
:interval="20"
:showMillisecond="true"
/>
<hbxw-count-down
start="2024/7/17 20:24:00"
end="2024/7/18 21:24:00"
:delimiter="['小时','分钟','秒']"
:commonStyle="{color: 'red',fontSize: '20px'}"
:showDay="false"
/>
<text class="title">高度自定义</text>
<hbxw-count-down start="2024/7/17 20:24:00" end="2024/7/17 21:24:00">
<template #content="{countDown}">
<view class="count-down-content">
<view>给你倒计时数据,由你自由定义怎么渲染</view>
<view>{{ countDown }}</view>
</view>
</template>
</hbxw-count-down>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
countDownFn(e) {
console.log('---- countDownFn ----:', e)
}
}
}
</script>
<style lang="scss" scoped>
.container{
display: flex;
flex-direction: column;
}
.count-down-content{
display: flex;
flex-direction: column;
}
.title{
width: 100%;
margin: 20px 0 10px 0;
font-size: 32rpx;
font-weight: bold;
}
</style>
API
Props
属性名 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
start | String/Number | '' | 是 | 倒计时开始时间,如果传number类型传入毫秒时间戳即可 |
end | String/Number | '' | 是 | 倒计时结束时间,如果传number类型传入毫秒时间戳即可 |
commonStyle | Object | {} | 否 | 自定义倒计时样式 |
showDay | Boolean | true | 否 | 倒计时是否到天 |
showMillisecond | Boolean | true | 否 | 倒计时是否到毫秒 |
interval | Number | 1000 | 否 | 倒计时时间间隔,如果要显示毫秒,时间间隔要小于1000 |
delimiter | Array | ['天',':',":", '', ''] | 否 | 分隔符 |
Events
事件名 | 说明 | 返回值 |
---|---|---|
count | 倒计时触发事件回调 | 返回{ diffVal: 余下时间毫秒数, countDown: {days, hours, minutes, seconds, milliseconds} |
end | 倒计时结束触发事件回调 | 无返回 |
倒计时组件分享出来