Components
Components are the building blocks of Vue applications. A component is essentially a Vue instance with pre-defined options. Registering a component in Vue using Composition is straightforward:
The sample component above is a simple button that increments a counter when clicked.
Structure
For this project, the setup script must be first, followed by the template and then the style. The style is optional.
The setup script is a single script tag with the attribute setup. The template is a single template tag. The style is a single style tag with the attribute scoped.
Directories
View components are stored in the src/views directory, while components that are used by views are stored in the src/components.
Reactivity
The ref function is used to create a reactive reference. This means that whenever the value of the reference changes, the component will be re-rendered.
If you want a reactive primitive variable, you must use the ref function.
Example
For objects, such as arrays, you must use the reactive function.
Example
Do NOT use the ref function for objects.