Currently working with Vue.js version 2.6.11
Trying to set up in main.js as follows:
import moment from 'moment'
moment.locale('nl');
Object.definePrototype(Vue.prototype, '$moment', { value: moment });
Encountering an error:
Uncaught (in promise) TypeError: Object.definePrototype is not a function
Attempted another approach:
moment.locale('nl')
Vue.prototype.$moment = moment
However, when running the page, receiving an error in console:
[Vue warn]: Error in render: "ReferenceError: moment is not defined"
Importing moment from 'moment'
directly in the Vue component works fine. However, looking to include it globally.
Any suggestions on how to resolve this issue?
Note that my Vue component looks like this:
<template>
<b-card no-body>
...
<p class="mb-0 text-muted">{{formatDate(data.date)}}</p>
...
</b-card>
</template>
<script>
import moment from 'moment'
export default {
props: ['data'],
methods: {
formatDate(date) {
return this.$moment(date).format('YYYY MM DD')
},
},
}
</script>