3👍
You can just use moment
in the Vuex by added it, in your store.js
file.
import moment from "moment";
And then you can use it, in your actions
and etc.
Take a look at my example here
2👍
You do not have a reference to this
when trying to create a Vuex store.
You can just add a reference to the import like this:
import moment from 'moment'
export default new Vuex.Store({ moment : moment})
2👍
You don’t need to use moment by this.$moment
, simply you need to install the moment via npm and tell Vue to use it globally
install
$ npm install vue-moment
To tell vue to use it globally
Vue.use(require('vue-moment'));
and then you can simply use moment("dddd, MMMM Do YYYY, h:mm:ss a")
in any component.
Check the docs here
- [Vuejs]-How to I scroll the page programmatically in Vue?
- [Vuejs]-How to get Component-scoped CSS WITHOUT using Single File Components?
- [Vuejs]-Display raw html in v-html attribute
- [Vuejs]-Webpack "Uncaught Type Error" when importing Firebase module into standard Vue.js project
Source:stackexchange.com