1 year ago

Dynamic loading of data - vuejs

Posted 1 year ago by ArchStanton

I have 3 different language files.

import { french } from '../fr/data.js';
import { englishUS } from '../us/data.js';
import { englishUK } from '../uk/data.js';

I load them all in and then just switch in the data I need based on a global language variable. ($root.language)

mounted() {

//switch statement based on $root.language


Is there a better way to make this more dynamic and only import the file I need?

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