Question - What are components and give an example?
Answer -
Components are reusable Vue instances with a name. They accept the same options as new Vue, such as data, computed, watch, methods, and lifecycle hooks(except few root-specific options like el).
Lets take an example of counter component,
// Define a new component called button-counter
Vue.component('button-counter', {
template: ''
data: function () {
return {
count: 0
}
},
})
Let's use this component inside a root Vue instance created with new Vue
var vm = new Vue({ el: '#app' });