Scope of components

In this recipe, we declared our component just above the Vue instance that will use it. This is okay because the component is in the same scope as the Vue root instance; the component is automatically registered by the instance.

In bigger applications, or when importing components, this might be a little more involved.

Inside Vue instances, there is an option called components that is equivalent to a registry of all the components that can be rendered inside its template. If a tag is encountered that is not standard (built-in in the browser) and not in this registry, Vue will log the following error:

 vue.js:2643 [Vue warn]: Unknown custom element: <light-bulb> - did you register the component correctly? For recursive ...

Get Vue.js 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.