I'm using the webpack template from vue-cli for my Vue project and I have both moment and moment-timezone installed in npm.
In my single file components, I've been able to get moment to work with moment-timezone by including the following import lines:
import moment from 'moment'
import moment_timezone from 'moment-timezone'
The moment_timezone object isn't ever used, but it seems to need to be there for moment.tz functions to work.
My questions are:
- Is this the proper way to load moment and moment-timezone in my setup?
- How do I load only the data from moment-timezone-with-data-2012-2022.min.js? I see it in the moment-timezone package's builds directory, but I'm unclear how to specify that that is the data that I would like to use.
import moment from 'moment-timezone'; Vue.prototype.$moment = moment;
Then you can access it within curly braces {{ $moment() }}, or within methods this.$moment(). – Mordacious