1 year ago

can't use moment with vue.js

Posted 1 year ago by afghany

i am trying to use moment with vue.js at laravel project and i installed moment by npm "npm install moment --save" and here is my bootstrap.js :

window.moment = require('moment');

and here is what i am trying to do 'inside vue component template' : {{window.moment(notification.created_at).formNow()}}

i got this error [Vue warn]: Property or method "window" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

[Vue warn]: Error in render: "TypeError: Cannot read property 'moment' of undefined"

found in

---> at resources/js/components/Notifications.vue

when try to use it from browser console it's working !

Please sign in or create an account to participate in this conversation.