• +91 9723535972
  • info@interviewmaterial.com

Vue JS Interview Questions and Answers

Question - Why is it recommended to use a key attribute for directive?

Answer -

It is recommended to use a key attribute for a directive to track each node's identity and thus reuse and reorder existing elements. We have to provide a unique key attribute for each item with in v-for iteration. An ideal value for the key would be the unique id of each item.

Example:

  
  {{item.name}}  
  
That's why it is always recommended to provide a key with v-for whenever possible unless the iterated DOM content is simple.

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners