Vue 显示 xxx 时间前的组件: vue-timeago

5,743 阅读1分钟

A timeago component for Vue.

Install

$ npm install --save vue-timeago

It's also available on NPMCDN: npmcdn.com/vue-timeago…

Usage

import VueTimeago from 'vue-timeago'

Vue.use(VueTimeago, {
  name: 'timeago', // component name, `timeago` by default
  locale: 'en-US',
  locales: {
    'en-US': require('vue-timeago/locales/en-US.json')
  }
})

Then in your lovely component:















A very basic demo: egoistian.com/vue-timeago

i18n support

For all supported languages, see /locales, feel free to submit a Pull Request to help us support more languages!

Development

I use rolling to build the cjs version bundle, and use vbuild to build the example. Install them globally and then see the npm scripts.

License

MIT © EGOIST