I’m using vue-cli and I’m wondering if there is a way to pass a variable into an import statemet?
What I mean is instead of import 'vue2-datepicker/locale/en'; if I can do soemthing like import 'vue2-datepicker/locale/{i18n.locale}';
where i18n.locale is coming from:
export const i18n = new VueI18n({
locale: 'en', // set locale
fallbackLocale: 'en',
messages,
})
export default i18n;
@lasjorg thanks for the suggestion!
I just tried but I’m getting import with a red line and "Declaration or statement expected" error.
What I tried was:
I don’t think the import/export works with template literals, I should probably have checked that before suggesting it. It looks like it has to be a string literal.