• js vue 时分秒倒计时


     props: {
          auctionList: {
            type: Array,
            default: function() {
              return [];
            }
          } 
        },

    onReady() {
            this.initList()
     },

    mounted(){
            this.auctionLists1 = this.auctionList;
            this.$set(this,'auctionLists1', this.auctionList);
            console.log(this.auctionLists1,'++++++++++++++++++++++++++')
        },

    initList(){
                setInterval(()=>{
                    this.auctionLists1.forEach((item,index)=>{
                        let _h = item.lastTime.split(':')[0] || 0;
                        let _m = item.lastTime.split(':')[1] || 0;
                        let _s = item.lastTime.split(':')[2] || 0;
                        let time = '';
                         console.log(111111111)
                            _s--;
                            if(_s == -1){
                                _m--;
                                _s = 59;
                            }
                            if(_m == -1){
                                _h--;
                                _m = 59;
                            }
                            
                            let _b = ((_h == 0) &&(_m == 0)&&(_s == 0))
                            if(_s<10){
                                _s = '0'+parseInt(_s);
                            }
                            if(_m<10){
                                _m = '0'+parseInt(_m);
                            }
                            if(_h<10){
                                _h = '0'+parseInt(_h);
                            }
                            if(_b){
                                time = '活动结束'
                                //clearTimeout(_t)
                            }else{
                                time = _h+':'+_m+':'+_s;
                            }
                            console.log(time)
                            item.lastTime = time;
                            
                    })
                }, 1000)
                setInterval(()=>{
                    this.$set(this,'auctionLists1', this.auctionLists1);
                }, 1000)
                return;
            }

  • 相关阅读:
    56 单词拆分
    基于蒙特卡洛的大规模电动汽车充电行为分析(Matlab代码实现)
    HTTP状态码及其描述
    深入剖析阻塞式socket的timeout
    【机器学习】逻辑回归LR的推导及特性是什么,面试回答?
    MyBatis处理表字段和实体类属性名不一致的情况及多对一映射关系的处理
    计算机专业毕业设计项目推荐06-工作室管理系统(Java+Vue+Mysql)
    输出分离与输出抽象
    【深度学习目标检测】二十一、基于深度学习的葡萄检测系统-含数据集、GUI和源码(python,yolov8)
    CPU与GPU到底有什么区别?
  • 原文地址:https://blog.csdn.net/m0_65730686/article/details/128176331