How carlitospc2810/ejercicio-vue-js works
Project type and purpose
• This is a single-page front-end application built with Vue.js.
• Its goal is to keep a collection of items in an in-memory array, display them in the UI, and compute derived values (e.g., totals, averages) in real time via Vue’s reactivity.
File structure
• index.html: Hosts the root
, includes the Vue.js runtime (via CDN or local script), and loads app.js.
• app.js: Defines a Vue instance (or Vue component) that holds the data array, methods to add/remove items, and computed properties for any required calculations.
• README.md: Confirms the core functionality—storing data in an array, rendering it, and performing calculations.
Key components
a. Browser / User
• Represents the end user interacting with the UI (clicking buttons, entering data).
b. index.html (Host)
• The static HTML page that loads the Vue runtime and mounts the Vue application.
c. Vue.js Runtime
• The framework layer that provides reactivity, template compilation, and DOM rendering.
d. app.js (Vue Application)
• Data Model: the in-memory JavaScript array.
• Methods: functions to mutate the array (add, remove, update items).
• Computed Properties: functions that derive metrics from the array (e.g., sums, counts).
• Template / View: the HTML markup within Vue templates or the el: '#app' region that binds to data and methods.
e. DOM / Rendered View
• The final HTML elements shown to the user, updated via Vue’s virtual DOM.
Relationships and data flows
• User → index.html UI: user triggers an event (e.g., form submission).
• UI Event → Vue Method (app.js): Vue captures the event and calls the appropriate method.
• Method → Data Model: the method mutates the array in memory.
• Data Model → Computed Properties: Vue detects the change, recomputes derived values.
• Computed Properties & Data Model → Template / Virtual DOM: Vue patches the DOM to reflect updated data and calculations.
• Virtual DOM → Real DOM: changes are flushed to the browser’s display.
Architectural patterns and principles
• MVVM-style partition:
• Model: JavaScript array of items
• ViewModel: Vue instance (data, methods, computed)
• View: Reactive template bound to the model
• Unidirectional data flow for mutations and reactivity loops
• Separation of concerns: index.html only hosts and loads assets; app.js contains application logic.