Components
When we're constructing a template for a web app, we can use HTML elements such as div
, table
, and span
. This variety of elements makes it easy to create whatever structures we need for organizing content on the page.
What if we could create our own custom elements, through, for example, my-element
? This would allow us to create reusable structures specifically designed for our app.
Components are a tool for creating custom elements in Vue.js. When we register a component, we define a template which renders as one or more standard HTML elements:
Figure 6.1. Components facilitate reusable markup and render as standard HTML
Registration
There are many ways to register a component, but the easiest is to use the component
 API method. The first argument is the name you want to give the component, the second is the configuration object. The configuration object will often include a template
 property to declare the component's markup using a string:
Vue.component('my-component', { template...