File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 13
13
> A Vue.js 2.0 MomentJS library
14
14
15
15
> It just wired moment api to custom filters in Vue : moment() and duration().
16
- > And also inject moment as this.$moment in your components.
16
+ > And also inject moment as ** this.$moment** in your components.
17
17
> So you have complete access to the whole api of moment in your templates and also the documentation from [ momentjs.com] ( https://momentjs.com/docs ) .
18
18
> Just keep in mind that the left value of the filter is the first argument in any of the moment and duration functions.
19
19
> You are good to go now :)
@@ -84,6 +84,20 @@ Raw JS for moments `moment(Date.now()).format("YYYY")` becomes `Date.now() | mom
84
84
85
85
Raw JS for duration ` moment.duration(500).humanize() ` becomes ` 500 | duration().humanize() `
86
86
87
+ ``` js
88
+ // in your components
89
+ methods: {
90
+ now () {
91
+ return this .$moment (Date .now ()).format ()
92
+ }
93
+ }
94
+
95
+ // it is also register as a global function in the Vue instance
96
+ // so you can do in vuex store or everywhere else to retrieve the same moment instance you initialized
97
+ import Vue from ' vue'
98
+ const thisYear = Vue .moment (Date .now ()).format (" YYYY" )
99
+ ```
100
+
87
101
### Custom moment instances
88
102
89
103
``` js
You can’t perform that action at this time.
0 commit comments