因为项目基于uniapp开发,所以就用uniapp的写法,只要知道具体放他,就可以自己 修改自己用了

样式 就不详细写了 自己写。

<view class="bw-cd">{{cdStr}}</view>
let setStartTime;export default {data() {return {cdTime:0,cdStr:'',};},methods:{/*清空倒计时*/clearStartTime(){return new Promise( (res,rel) => {clearInterval(setStartTime);setStartTime = null; this.cdStr = '';res();})},formatSeconds(t) {let mi = 60,hh = mi*60,dd = hh*24;let d = this.formatBit( Math.floor(t/dd)),h = this.formatBit( Math.floor((t - d*dd)/hh)),m = this.formatBit( Math.floor((t - d*dd - h*hh)/mi)),s = this.formatBit( Math.floor((t - d*dd - h*hh - m*mi)));let tstr = d+'天'+h+'小时'+m+"分"+s+'秒';return tstr;},initTime(time){this.clearStartTime().then( ()=> {this.cdTime = Math.floor(time/1000);console.log(this.cdTime);setStartTime = setInterval(() => {this.cdTime--;this.cdStr = this.formatSeconds(this.cdTime);// console.log(this.cdStr);if (this.cdTime <= 0) {clearInterval(setStartTime)this.$emit('bwCountdown');}}, 1000)})},formatBit(v){v = +vreturn v > 9 ? v : '0' + v},}}
.bw-cd{flex: 1;height: 100%;display: flex;align-items: center;justify-content: center;
}

最后附上 插件下载地址

毫秒转换天时分秒倒计时相关推荐

  1. mysql 毫秒转换为天时分秒

    实现逻辑,指定一个毫秒值,通过sql转换为秒,再转换为剩余X天X小时X分X秒,通常用来计算活动剩余倒计时. set @time = 671218437/1000; -- 毫秒转换为天时分秒(67121 ...

  2. Python 函数 毫秒转换为时分秒

    Python 函数 毫秒转换为时分秒 def TimeConverter():ms = int(input('请输入毫秒数:'))# 保留两位小数,但若ms太小,h就会显示为0.s = round(m ...

  3. js 毫秒转天时分秒

    js 毫秒转天时分秒 function formatDuring(ms) {const days = parseInt(ms/ (1000 * 60 * 60 * 24));const hours = ...

  4. html天时分秒倒计时,倒计时(天 时 分 秒)(原创)

    //格式化时间 Date.prototype.format = function(format) { /* * 使用例子:format="yyyy-MM-dd hh:mm:ss"; ...

  5. js实现天时分秒倒计时

    很久很久没更新文章啦!刚好3个月,前段时间都在忙各种事,忙着公司的项目,忙着自己的小项目,还要忙着生活,回想起来,还是挺充实的,感谢一直以来支持我的朋友们.很久没来了,没想到粉丝都增加到了100多了, ...

  6. 2022-07-20 工作记录--React-js将时间戳转换成“天时分秒” + “天时分秒”的倒计时

    一.实现效果 假如后端返了两个数据:当前时间的13位时间戳currentTimestamp.到期时间的13位时间戳expireTimestamp,想实现"还有多久到期的时间"的倒计 ...

  7. 毫秒转换成js年月日时分秒,标准时间转换js

    毫秒转换成js年月日时分秒/标准时间转换js时分秒 var format = function(time, format){var t = new Date(time);var tf = functi ...

  8. 商城倒计时(时分秒倒计时、分秒毫秒倒计时)

    1.布局用法  引用项目coutdowntimelibrary的CountDownView 如下 <carraydraw.com.coutdowntimelibrary.countdown.Co ...

  9. js倒计时天时分秒php,js实现时分秒倒计时

    本文实例为大家分享了js实现时分秒倒计时的具体代码,供大家参考,具体内容如下 js时分秒毫秒倒计时 //js部分 function countTime(value) { //获取当前时间 var da ...

最新文章

  1. 51单片机教程哪个好?
  2. 海天学院的打造IT人才讲座准备
  3. 开源 java CMS - FreeCMS2.7 移动端首页静态化
  4. 传统IP网络与MPLS网络转发的区别
  5. LeetCode 78. 子集
  6. Qt Creator 运行s60 Emulator
  7. 千千万万的IT开发工程师路在何方?
  8. jvm需要多长时间进行转义分析? 可能比您想象的要长。
  9. 找出数组中两个只出现了一次的数
  10. linux系统下替换图片,Linux(ubuntu系统)下使用FreeImage库
  11. 安卓应用安全指南 4.2.2 创建/使用广播接收器 规则书
  12. Android 驱动(17)---如何在linux中添加新的kernel module
  13. 我的MySQL数据库学习笔记
  14. 作为面试官,我是怎么快速判断程序员能力的?
  15. PHP正则怎样词语过滤,如何用正则替换敏感词?敏感词过滤? - SegmentFault
  16. python中实用的collections模块
  17. gx works2 版本号_GX Works2 64位
  18. 微信小程序开发:各种页面特效集合(持续更新)
  19. 《指弹:Dream Catcher》
  20. 大庭广众、朗朗乾坤之下,老师竟然带十男两女拉上窗帘、关上门做出这种不可描述之事...

热门文章

  1. DELL设备维保查询方法
  2. Robust Network Traffic Classification
  3. traffic-filter
  4. e3mall商城的归纳总结1之项目的架构
  5. 施耐德PLC网关如何实现PLC远程上下载和编程配置?
  6. ASP.NET Web API与Owin OAuth:使用Access Toke调用受保护的API
  7. 扩展欧几里得算法求逆元---乘法密码
  8. arcgis怎么压缩tif文件_怎么将pdf文件压缩到指定大小?
  9. Linux网络编程之PHP聊天室Workerman-chat
  10. 游戏系列~苍穹世界(5)