Currently, I am extracting a language setting from the DOM and assigning it to a global
Vue.js variable in the following manner:
const language = document.querySelector('html').getAttribute('lang');
Vue.prototype.$language = language;
This method works effectively, but I recently came across another approach using a Vue.js event bus as shown below:
Object.defineProperties(Vue.prototype, {
$bus: {
get() {
return EventBus;
}
}
});
I am curious about the actual difference between these two methods and whether there is a more recommended way to achieve the same outcome?