Closed blackinitial closed 5 years ago
Make sure you did installed Nuxt Moment:
yarn add moment @nuxtjs/moment
OR npm i moment @nuxtjs/moment
@teledirigido i was installed @nuxtjs/moment
and moment
@blackinitial I could not reproduce. Share your setup
@ricardogobbosouza i use default setup from fresh nuxtjs . Only add moment on modules nuxt.config.js
@blackinitial Try re-install dependencies
@blackinitial it worked?
I canceled using this library, I was removed. Finally, I implement moment with plugin methods nuxt js.
@manniL , @pi0 This can also be closed, this error no longer exists
Hi!
After getting this error with all my modules, i upgrade my version of npm and now it's working I hope this can be helpful !
(same for yarn if you using it)
same error here, when i call function in template
{{ $moment(post.post_date).format('HH:mm') }} // works well
it works just fine, when it's used in mounted() it's fine too
mounted: function() {
console.log(this.$moment) // works well
},
but when i want to use it in apollo query variable, then it's undefined
apollo: {
posts: {
query() {
return POSTS_QUERY
},
update: data => data.postsElastic,
variables() {
// Use vue reactive properties here
return {
date_after: this.$moment().format() // undefined
}
}
}
}
how to use nuxt moment?
i was added nuxt moment on module nuxt.config.js and i try to call moment on mounted() a page but has undefined $moment.
nuxt.config.js
pages