• +91 9723535972
  • info@interviewmaterial.com

Vue JS Interview Questions and Answers

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' });

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners