zoukankan      html  css  js  c++  java
  • 一个随时更新的js库

    1.src同级建commFunction=》timer.js

    2.main.js引入

    import time from '../commonFunction/time'
    Vue.prototype.time=time
    =======================================

    情况一1.时间戳

    // 时间戳转时间 2020-4-24 00:30:00
        timeStamp(val) {
            val = val.toString()
            if(val.length == 10) {
              let time = val * 1000;
              let timestamp4 = new Date(time);
              return (timestamp4.toLocaleDateString().replace(///g, "-") +" " + timestamp4.toTimeString().substr(0, 8));
            } else {
              let timestamp4 = new Date(val);
              return (timestamp4.toLocaleDateString().replace(///g, "-") +" " +timestamp4.toTimeString().substr(0, 8));
            }
        },
        // 2017-4-8 14:11:33转2017-04-08 14:11:33
        handeldate(m){
            let o = m[0]+m[1]+m[2]+m[3]
            if(m.length==18){
                if(m[6]=='-'){
                    return o+m[4]+'0'+m[5]+m[6]+m[7]+m[8]+m.slice(9)
                }
                if(m[7]=='-'){
                    return o+m[4]+m[5]+m[6]+m[7]+'0'+m[8]+m.slice(9)
                }
            }else if(m.length==17){
                return o+m[4]+'0'+m[5]+m[6]+'0'+m[7]+m.slice(8)
            }else{
                return m
            }
        }
    页面使用:
    appList.forEach(element => {
                  element.create_time = this.time.handeldate(this.time.timeStamp(element.create_time))
                });
  • 相关阅读:
    TestNG(五) 5-7 套件测试
    TestNG(四) 基本注解BeforeSuite和AfterSuite
    【ES6】知识点汇总--1>10
    【vue】移动端项目初始化问题汇总
    【vue】单页面应用和多页面应用
    【Vue】单文件组件和路由
    【Vue】项目代码结构介绍
    【Docker】Centos7下Docker安装及Python环境配置
    Django面试题汇总
    vue面试题汇总
  • 原文地址:https://www.cnblogs.com/wd163/p/13213773.html
Copyright © 2011-2022 走看看