zoukankan      html  css  js  c++  java
  • 小程序里面做倒计时

    第一步,建立util.wxs

    第二步:util.wxs里面的内容

    module.exports = {
        formatTimeLeft: function(timeleft){ 
            var day = 0;
            var hour = 0;
            var min = 0;
            var second = 0;
            //计算天
            day =  parseInt(timeleft / (24 * 60 * 60));
            hour = parseInt((timeleft - day * (24 * 60 * 60)) / (60 * 60));
            min =  parseInt((timeleft - day * (24 * 60 * 60) - hour * (60 * 60))/ 60  );
            second = parseInt(timeleft - day * (24 * 60 * 60) - hour * (60 * 60) - min * 60);
            if(day > 0){
                return day+""+hour+""+min+"";
            }else{
               return  hour+""+min+""+second+"";
            }
        },
        dateteap: function (timestamp) {
          var date = getDate(timestamp)
          var year = date.getFullYear()
          var month = date.getMonth() + 1
          var day = date.getDate()
    
          var hour = date.getHours()
          var minute = date.getMinutes()
          var second = date.getSeconds()
          return year+'-'+month+'-'+day
        },
        getday:function(times) {
            return Math.round(times / 86400)
        },
        newdate:function(timestamp){
          var date = getDate(timestamp)
          var year = date.getFullYear()
          var month = date.getMonth() + 1
          var day = date.getDate()
    
          var hour = date.getHours()
          var minute = date.getMinutes()
          var second = date.getSeconds()
          return month+''+day+""
        }    
    }

    第三步,在要渲染的文件中引入wxs模块

    第四步:页面显示

  • 相关阅读:
    ETL Pentaho Data Integration (Kettle) 插入/更新 问题 etl
    Value Investment
    sqlserver 2008r2 表分区拆分问题
    HTTP与HTTPS的区别与联系
    别人分享的面经
    饥人谷开放接口(教程)
    java内存泄漏
    单例模式
    Maven项目上有小红叉咋办
    Socket通信1.0
  • 原文地址:https://www.cnblogs.com/antyhouse/p/9361221.html
Copyright © 2011-2022 走看看