zoukankan      html  css  js  c++  java
  • 详情秒杀倒计时-vue

    HTML:

    <div>{{countDownList}}</div>

    script:

    export default {
      data() {
        return {
          countDownList: '00天00时00分00秒',
          actEndTime: '2018-11-19 18:50:00'
        };
      },
      created() {
        this.countDown();

      },

      methods: {
        timeFormat(param) {
          return param < 10 ? '0' + param : param;
        },
        countDown(it) {
          var interval = setInterval(() => {
            // 获取当前时间,同时得到活动结束时间数组
            let newTime = new Date().getTime();
            // 对结束时间进行处理渲染到页面
            let endTime = new Date(this.actEndTime).getTime();
            let obj = null;
            // 如果活动未结束,对时间进行处理
            if (endTime - newTime > 0) {
              let time = (endTime - newTime) / 1000;
              // 获取天、时、分、秒
              let day = parseInt(time / (60 * 60 * 24));
              let hou = parseInt(time % (60 * 60 * 24) / 3600);
              let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
              let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
              obj = {
                day: this.timeFormat(day),
                hou: this.timeFormat(hou),
                min: this.timeFormat(min),
                sec: this.timeFormat(sec)
              };
            } else { // 活动已结束,全部设置为'00'
              obj = {
                day: '00',
                hou: '00',
                min: '00',
                sec: '00'
              };
              clearInterval(interval);
            }
            this.countDownList = obj.day + '天' + obj.hou + '时' + obj.min + '分' + obj.sec + '秒';
          }, 1000);
        }
      }

    }

  • 相关阅读:
    python的使用
    SFM(structure from motion)
    linux 常用命令
    opencv图像操作
    两圆位置判断
    nat123动态域名解析软件使用教程
    IIS负载均衡
    Oracle 查询表信息(字段+备注) .
    【原创】开源.NET排列组合组件KwCombinatorics使用(三)——笛卡尔积组合
    visual studio 2013使用技巧
  • 原文地址:https://www.cnblogs.com/CMing/p/9818013.html
Copyright © 2011-2022 走看看