Module-based component loading¶
Module-based component loading is a technique for developing Vue.js applications that allows the browser to execute ES6 modules natively, without relying on a build step or transpilation tools like Babel^[600-developer-frontend-vue-vue-module.md].
Implementation¶
To enable this functionality, the HTML entry point must specify type="module" within the <script> tags^[600-developer-frontend-vue-vue-module.md]. This attribute informs the browser to treat the linked JavaScript files as ECMAScript modules, enabling features such as import and export statements directly in the client environment^[600-developer-frontend-vue-vue-module.md].
Component Structure¶
In a module-based architecture, a component is typically defined in a separate JavaScript file (e.g., SingleFileComponent.js) which exports a default object containing the Vue component options^[600-developer-frontend-vue-vue-module.md]. The main application file (e.g., app.js) then imports this component using the standard ES6 syntax import ComponentName from './ComponentFile.js'^[600-developer-frontend-vue-vue-module.md].
This approach allows developers to organize code into distinct files and logic units while maintaining the ability to run the application directly in the browser^[600-developer-frontend-vue-vue-module.md].
Related Concepts¶
- [[Vue.js]]
- [[ES6 Modules]]
- [[Component-based architecture]]
Sources¶
^[600-developer-frontend-vue-vue-module.md]