https://github.com/slimcheng/vue-date-format
适用于vue2.0的时间格式化、美化插件
https://github.com/slimcheng/vue-date-format
date-formatting timeago timeago-vue vue vue-dateformat
Last synced: 8 months ago
JSON representation
适用于vue2.0的时间格式化、美化插件
- Host: GitHub
- URL: https://github.com/slimcheng/vue-date-format
- Owner: slimcheng
- License: mit
- Created: 2018-01-26T07:34:42.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-03T09:27:16.000Z (over 7 years ago)
- Last Synced: 2024-04-25T13:20:21.793Z (over 1 year ago)
- Topics: date-formatting, timeago, timeago-vue, vue, vue-dateformat
- Language: Vue
- Size: 252 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vue-date-format
Date format component for Vue2.0 | [DEMO](https://slimcheng.github.io/vue-date-format/example/index.html)
日期格式化、美化插件
## Installation
``` bash
# npm
npm install vue-date-format
# yarn
yarn add vue-date-format
```
## Import
``` bash
// main.js
import vueDateFormat from 'vue-date-format'
Vue.use(vueDateFormat)
```
## Usage
### In template
``` bash
```
### Set config value
``` bash
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/String |Date或时间字符串,不传默认为当前时间 | new Date() |
| type | 类型(格式化/多久以前) | String |'fmt'/'ago' | 'fmt' |
| autoUpdate | 是否自动更新时间;type为‘fmt’时,开启自动更新,会忽略传入的time值,自动展示系统时间 | Boolean |true/false | false |
| autoTime | 自动更新间隔时间(autoUpdate为false设置无效果) | Number |正整数,单位为秒(s) | 30 |