If you want to follow the Vue way of adding data to your project, importing your data object in main.js
is the recommended approach. By creating an instance property and adding it to the Vue prototype, you can easily access this data in all child components attached to that instance:
main.js
import global_data from `./Data`;
... // Other imports, Vue.use, Vue.component, etc.
Vue.prototype.$global_data = global_data; // Adds object to Vue's prototype
new Vue({
... // Create Vue instance with desired config etc.
});
This allows you to access the data throughout your Vue components using this.$global_data
. Feel free to name the property as you like, following the convention of prefixing instance properties with a $
.