Skip to content

Juceztp/vue-dayjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue-dayjs

NPM Version size license

A small wrapper for integrating dayjs to Vuejs

Dayjs is a minimalist (Fast 2kB) JavaScript library for modern browsers with a largely Moment.js-compatible API. If you use Moment.js, you already know how to use Day.js.

Usage (Recommended) (Without installing this library)

plugins/Dayjs.js

import Vue from 'vue';
import dayjs from 'dayjs';

Object.defineProperties(Vue.prototype, {
    $date: {
        get() {
            return dayjs
        }
    }
});

main.js

//Plugins
import '@/plugins/Dayjs';

If you need to use an extra plugin from the dayjs library. example

plugins/Dayjs.js

import Vue from 'vue';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';

dayjs.extend(relativeTime);

Object.defineProperties(Vue.prototype, {
    $date: {
        get() {
            return dayjs
        }
    }
});

Usage

npm install vue-dayjs-plugin
import VueDayjs from 'vue-dayjs-plugin'

Vue.use(VueDayjs)

Example

JS

this.$date('2018-08-08').format('DD/MM/YYYY');

HTML

<span> {{ $date('2018-08-08').format('DD/MM/YYYY') }} </span>

License

MIT

About

A small wrapper for integrating dayjs to Vuejs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •