Components
Components
What are Components?
Components are one of the most powerful features of Vue.js. They help you extend basic HTML elements to encapsulate reusable code. At a high level, Components are custom elements that Vue.js’ compiler would attach specified behavior to. In some cases, they may also appear as a native HTML element extended with the special is
attribute.
Using Components
Registration
We’ve learned in the previous sections that we can create a component constructor using Vue.extend()
:
var MyComponent = Vue.extend({ // options... })
To use this constructor as a component, you need to register it with Vue.component(tag, constructor)
:
// Globally register the component with tag: my-compon