[Vuejs]-How to use vue-moment in vuex

4👍

When using vue-moment in a vuex module you can’t use this.$moment but you can use it like this:

import Vue from 'vue'
...
Vue.moment(someTime)

2👍

First, use it as a plugin Vue.use(require('vue-moment')); before starting the instance of the vue instance

secondly you can use it like this as an exampleVue.moment().. just replicated and it worked

this is how the start of my file looks like

import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);
Vue.use(require('vue-moment'));

export default new Vuex.Store({
//the rest of the state.js file
})

👤Dabees

Leave a comment