brockpetrie / vue-moment

Handy Moment.js filters for your Vue.js project.
MIT License
1.31k stars 121 forks source link

vue moment not working when used in axios #135

Open Benoit1980 opened 4 years ago

Benoit1980 commented 4 years ago

Hello,

I am using Laravel with vue.js

I added this to the app.js: import Moment from 'vue-moment'; Vue.use(Moment);

In my components it works when I used vue moment like this:

{{item.last_login | moment("DD-MM-YYYY HH:mm") }}

But as soon as I try to use it in an axis request it fails. I tried this:

   formData.append('calendar', moment(String(this.field.calendar)).format('YYYY-MM-DD hh:mm')); 

Also tried this:

   formData.append('calendar', $moment(String(this.field.calendar)).format('YYYY-MM-DD hh:mm')); 

Both of them shows this error:

[Vue warn]: Error in v-on handler: "ReferenceError: $moment is not defined"
found in
<AddGamesComponent> at resources/js/components/Listings/AddGamesComponent.vue
       <Root>

Any idea why please?

Thank you.

BrockReece commented 4 years ago

Try this.$moment