Components Basics — Vue.js
v2.vuejs.org › v2 › guideComponents Basics — Vue.js Components Basics Watch a free video course on Vue School Base Example Here’s an example of a Vue component: // Define a new component called button-counter Vue. component ( 'button-counter', { data: function () { return { count: 0 } }, template: '<button v-on:click="count++">You clicked me { { count }} times.</button>'
Template Syntax | Vue.js
vuejs.org › guide › essentialsVue uses an HTML-based template syntax that allows you to declaratively bind the rendered DOM to the underlying component instance's data. All Vue templates are syntactically valid HTML that can be parsed by spec-compliant browsers and HTML parsers. Under the hood, Vue compiles the templates into highly-optimized JavaScript code.
Component Events | Vue.js
vuejs.org › guide › componentsComponent Events | Vue.js Component Events This page assumes you've already read the Components Basics. Read that first if you are new to components. Emitting and Listening to Events A component can emit custom events directly in template expressions (e.g. in a v-on handler) using the built-in $emit method: template <!--
Components Basics | Vue.js
vuejs.org › guide › essentialsvue <script> import ButtonCounter from './ButtonCounter.vue' export default { components: { ButtonCounter } } </script> <template> <h1>Here is a child component!</h1> <ButtonCounter /> </template> To expose the imported component to our template, we need to register it with the components option.