1.1.2 • Published 6 years ago

vue-date-format v1.1.2

Weekly downloads
8
License
MIT
Repository
github
Last release
6 years ago

vue-date-format

Date format component for Vue2.0

日期格式化、美化插件

Installation

# npm
npm install vue-date-format

# yarn
yarn add vue-date-format

Import

// main.js

import vueDateFormat from 'vue-date-format'
Vue.use(vueDateFormat)

Usage

In template

<vueDateFormat :format="format" :time="time" :type="type" :autoUpdate="autoUpdate"></vueDateFormat>

Set config value

data () {
    return {
        format:'yyyy年MM月dd日 hh:mm:ss',
        time:new Date(), //时间或字符串(eg:'2017-12-12'),
        type:'fmt',
        autoUpdate:false
    }
}
参数说明类型可选值默认值
format格式化String-'yyyy-MM-dd hh:mm:ss'
time需要展示的时间Date/StringDate或时间字符串,不传默认为当前时间new Date()
type类型(格式化/多久以前)String'fmt'/'ago''fmt'
autoUpdate是否自动更新时间;type为‘fmt’时,开启自动更新,会忽略传入的time值,自动展示系统时间Booleantrue/falsefalse
autoTime自动更新间隔时间(autoUpdate为false设置无效果)Number正整数,单位为秒(s)30