Easy integration between Nuxt.js and Moment.js
Install with npm:
npm i nuxt-moment
nuxt.config.js:
module.exports = {
modules: [
// Simple usage
'nuxt-moment'
]
}
export default {
data () {
return {
date: this.$moment().format('LTS')
}
},
computed: {
computedDate () {
return this.$moment(new Date).format('LL')
}
},
methods: {
getDate () {
return this.$moment()
}
}
}
export default function({ $moment }) {
console.log($moment().format('LTS'))
}
export const state = () => ({
date: new Date()
})
export const mutations = {
MUTATION (state) {
state.date = this.$moment().day(10)
}
}
export const actions = {
action ({state, commit}) {
commit('SAMPLE_MUTATIONS', this.$moment().day(5))
}
}
Copyright (c) Dev.DY