Closed nzxt closed 5 years ago
@nzxt I think i had to solve a similar issue, to use the existing instance you can do the following
import momentDurationFormatSetup from 'moment-duration-format'
export default ({ app }, inject) => {
momentDurationFormatSetup(app.$moment)
}
@nzxt I think we can close this
This doesn't work for me, could we reopen? My code also uses locales.
const momentDurationFormatSetup = require("moment-duration-format");
export default ({app}, inject) => {
const {$moment} = app;
momentDurationFormatSetup(app.$moment);
inject('moment', (...args) => {
const localMoment = $moment(...args);
localMoment.locale(app.i18n.locale);
return localMoment;
});
};
An update.
This works, i had to set app.$moment!
import moment from 'moment-duration-format'
import momentDurationFormatSetup from 'moment-duration-format'
export default ({app}, inject) => {
let {$moment} = app;
momentDurationFormatSetup($moment);
inject('moment', (...args) => {
const localMoment = $moment(...args);
localMoment.locale(app.i18n.locale);
return localMoment;
});
app.$moment = $moment;
};
Thanks, great module! My question is next: When i use moment.js as plugin i wrote:
How can i extend 'moment.js' with 'moment-duration-format' in your module?