Performance: TransitionGroup for lists
This affects the rendering performance and visual stability when animating list items during addition, removal, or reordering.
<TransitionGroup tag="ul" name="fade" appear> <li v-for="item in items" :key="item.id">{{ item.text }}</li> </TransitionGroup>
<ul> <li v-for="item in items" :key="item.id">{{ item.text }}</li> </ul>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| List without TransitionGroup | Minimal DOM ops, direct add/remove | Multiple reflows per item change | High paint cost due to abrupt changes | [X] Bad |
| List with TransitionGroup and CSS transitions | Same DOM ops plus animation wrappers | Single reflow with animated layout shifts | Moderate paint cost with smooth transitions | [OK] Good |
<TransitionGroup> in Vue?<TransitionGroup> in Vue?tag attribute sets the HTML element used as the wrapper in <TransitionGroup>.<TransitionGroup tag="ul"> uses tag="ul", which is the correct syntax. Others use invalid attributes like wrapper, element, or container.items array is ["A", "B"]?
<TransitionGroup tag="ul" name="fade">
<li v-for="item in items" :key="item">{{ item }}</li>
</TransitionGroup>tag="ul", so the wrapper is a <ul> element. The list items have unique keys from the item values.<TransitionGroup>:
<TransitionGroup tag="ul" name="slide">
<li v-for="item in items">{{ item }}</li>
</TransitionGroup>:key attribute to track changes for animation.tag="ul" and name="slide" are valid. The v-for syntax is correct.<TransitionGroup> using a custom CSS animation named "bounce". The tasks array may have duplicate names. Which approach ensures smooth animations without glitches?task + index) creates unique keys even if names repeat, ensuring smooth animations.name="bounce" on <TransitionGroup> applies the correct CSS animation classes.Pass the test and this pattern moves unknown