Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

vue3 components Property

Vue3 components Property


Vue3 Options API Vue3 Options API

In Vue 3,components The property is used to register local components. Through components components registered via the property can only be used within the current component and will not affect other components. This allows us to reuse the same component name in different components without causing naming conflicts.


How to Use the Components Property?

Use components property is very simple. You only need to define a script object within the components section of the Vue component, then add the component you want to register as a property of that object.

1. Example Code

Example

2. Code Explanation


Why Use the Components Property?

Use components Registering local components via the property has the following benefits:

  1. Modularity: Splitting components into smaller parts makes the code easier to maintain and understand.
  2. Reusability: The same component can be reused across different components without redefining it.
  3. Namespacing: Local components are scoped to the current component, avoiding global naming conflicts.

Notes


Vue3 Options API Vue3 Options API