• +91 9723535972
  • info@interviewmaterial.com

Vue JS Interview Questions and Answers

Question - Give an example to demonstrate how do you reuse elements with key attribute?

Answer -

Vue.js always facilitates us to render elements as efficiently as possible. So, it is possible to reuse the elements instead of building them from scratch. But this can create problems in few scenarios. For example, if you try to render the same input element in both v-if and v-else blocks then it holds the previous value as follows:

  
  
In the above case, we should not reuse it. It is better to make both input elements as separate by applying key attribute as follows:

  
  
In the above example, both inputs are independent and do not impact each other.

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners