plugins/filter.js

import Vue from 'vue'
// 时间格式化
// 用法:<div>{{data | dataFormat('yyyy-MM-dd hh:mm:ss')}}</div>
Vue.filter('formatDate', function (value, fmt) {
let getDate = new Date(value);
let o = {
'M+': getDate.getMonth() + 1,
'd+': getDate.getDate(),
'h+': getDate.getHours(),
'm+': getDate.getMinutes(),
's+': getDate.getSeconds(),
'q+': Math.floor((getDate.getMonth() + 3) / 3),
'S': getDate.getMilliseconds()
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (getDate.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (let k in o) {
if (new RegExp('(' + k + ')').test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
}
}
return fmt;
})

nuxt.config.js

 plugins: ['@/plugins/element-ui', '@/plugins/filters.js'],

vue filter方法-时间格式化的更多相关文章

  1. vue+element ui 时间格式化

    <el-table-column prop="startTime" label="日期" width="200" align=&quo ...

  2. elementUI 时间格式化(一般方法)

    1.html: ... <el-table-column prop="updateTime" label="更新时间" width="160&q ...

  3. Python中日期和时间格式化输出的方法

    本文转自:https://www.jb51.net/article/62518.htm 本文实例总结了python中日期和时间格式化输出的方法.分享给大家供大家参考.具体分析如下: python格式化 ...

  4. SQLAlchemy中时间格式化及将时间戳转成对应时间的方法-mysql

    https://blog.csdn.net/guoqianqian5812/article/details/80175866 方法很简答,都是借助于mysql数据库提供的函数将时间格式化方法 func ...

  5. 【转】Hudson插件Email-Ext邮件模板时间格式化的解决方法

    原文地址:http://www.cnblogs.com/haycco/archive/2012/03/20/3031397.html 最近因对Hudson版本进行了升级为2.2.0,所以各方面都在搞项 ...

  6. js 中时间格式化的几种方法

    1.项目中时间返回值,很过时候为毫秒值,我们需要转换成 能够看懂的时间的格式: 例如: yyyy-MM-dd HH:mm:ss 2.处理方法(处理方法有多种,可以传值到前端处理,也可以后台可以好之后再 ...

  7. javascript 时间格式化方法

    对jquery进行扩展的方法: //对时间格式化(jquery方法扩展) Date.prototype.Format = function (fmt) { //author: meizz var o ...

  8. VUE过滤器的使用 vue 时间格式化

    过滤器介绍 官方教程地址:https://cn.vuejs.org/v2/guide/filters.html 过滤器常被用于一些文本格式化 我们可以自定义过滤器,可以实现各种各样的功能. vue时间 ...

  9. Vue 变异方法filter和正则RegExp对评论进行搜索

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

随机推荐

  1. Gson学习文档

    Gson:学习系列 http://www.codeceo.com/article/java-json-api-gson-1.html

  2. sencha touch 目录结构

    1.index.html 整个html 中只加载一个 development.js 2.development.js development.js会根据app.json中的样式和脚本定义来加载样式和脚 ...

  3. hbase.client.keyvalue.maxsize的默认值

    hbase的列族的最大值是在hbase配置里的hbase.client.keyvalue.maxsize,默认大小为10M,即 10485760 . http://eclecl1314-163-com ...

  4. [web 前端] css3 transform方法常用属性

    cp from : https://www.cnblogs.com/chrxc/p/5126569.html css3中transform方法是一个功能强大的属性,可以对元素进行移动.缩放.转动.拉长 ...

  5. ConditionalOnProperty

    配置Spring Boot通过@ConditionalOnProperty来控制Configuration是否生效 1.matchIfMissing属性:从application.properties ...

  6. js 图片base64转file文件的两种方式

    js 图片base64转file文件的两种方式 https://blog.csdn.net/yin13037173186/article/details/83302628 //将base64转换为bl ...

  7. 【Android自己定义控件】圆圈交替,仿progress效果

    还是我们自定View的那几个步骤: 1.自己定义View的属性 2.在View的构造方法中获得我们自己定义的属性 3.重写onMesure (不是必须) 4.重写onDraw 自己定义View的属性 ...

  8. Java中Lambda表达式的使用(转)

    https://www.cnblogs.com/franson-2016/p/5593080.html 简介(译者注:虽然看着很先进,其实Lambda表达式的本质只是一个"语法糖" ...

  9. 关于VC预定义常量_WIN32,WIN32,_WIN64

    VC2012 下写 Windows 程序时,有时需要判断编译环境.在之前的文章<判断程序是否运行在 Windows x64 系统下.>里说过如何在运行期间判断系统环境,但在编译时如何判断? ...

  10. OpenCV 学习笔记 07 支持向量机SVM(flag)

    1 SVM 基本概念 本章节主要从文字层面来概括性理解 SVM. 支持向量机(support vector machine,简SVM)是二类分类模型. 在机器学习中,它在分类与回归分析中分析数据的监督 ...