VueJs basic interview questions?

What are life cycle hooks in VueJs?

  • beforeCreate - The first component in the creation hooks. This allows us to perform actions before our component has been added to DOM. We don't have access to DOM inside of this hook.
  • Created -This hook is invoked when Vue has set up events and data observation. Here, events are active and access to reactive data is enabled though templates have not yet been mounted or rendered.
  • beforeMount - The beforeMount hooks runs right before the initial render happens and after the template or render functions have been complied.
  • Mounted - This is a most used hook and you will have full access to the reactive component, templates, and rendered DOM (via. this.$el). The most frequently used patterns are fetching data for your component.
  • beforeUpdate - This hook runs after data changes on our component and the update cycle begins. But it runs right before the DOM is patched and re-renders.
  • Updated - This hook runs after data changes on your component and the DOM re-renders.
  • beforeDestroy -  This hook will run before destroying vue instance.
  • Destroyed - This hooks is called after your component has been destroyed, its directives have been unbound and its event listeners have been removed.

What is data binding in VueJs?

  • A data binding means an interaction between user interface and a model property.
  • When we are implementing data binding we use  v-bind & v-html.
  • We can perform data binding on 
    • HTML attributes binding.
    • HTML content binding.
    • FORM inputs binding.
    • HTML class binding.

What is two way data binding?

  • When data is bound from the DOM back to JS.
  • Here, one time it will update in data property and other time it will update in HTML - this is case of two way binding.
  • For two way data binding we use v-model directive.

What are event modifiers in VueJs?

  • In VueJs we are having four types of event modifiers - once, prevent, stop, capture
  • We are using event modifiers to change the default behavior of events.

What is the main difference between method and computed property?

  • The main difference between a computed property and a method is that computed properties are cached and invoke/change only when their dependencies change. Whereas a method will evaluate every time it's called.

What is difference between mounted & computed?

  • mounted is a lifecycle hook, a method which is called as soon as the Vue instance is mounted on the DOM.
  • computed is an object containing methods that returns data.

What is computed in VueJs?

  • Computed properties can be used to do some quick calculations of properties that are dispalyed in view. These calculations will be cache and will be updated when needed.
  • Computed properties allows us to have model specific, complex value computed for the view.These values will be bound to dependency values and only update when requird.
What is scoped in VueJs?
When a <style> tag has the scoped attribute, its CSS will apply to elements of the current component only.


Comments

Popular posts from this blog

Basic Terminology

What is normalization in DBMS?

Object oriented programming concepts in PHP