Utilizing vue.js, I crafted a small data filter tool that boasts sleek transitions for added flair. However, I encountered an issue with displaying a message when there are no results matching the current filters. Here's what I attempted:
<transition-group …>
<div class="SOME_CLASSES" v-for="x in RESULTS" :key="x.id">…</div>
<div class="OTHER_CLASSES" v-if="!RESULTS">Sorry, no results.</div>
</transition-group>
Unfortunately, this setup is not functioning as expected and generates a warning:
[Vue warn]: children must be keyed:
I pondered moving the message outside the <transition-group>
:
<transition-group …>
<div class="SOME_CLASSES" v-for="x in RESULTS" :key="x.id">…</div>
</transition-group>
<div class="OTHER_CLASSES" v-if="!RESULTS">Sorry, no results.</div>
However, this approach sacrifices the attractive animation that accompanies the display of the message.
Is there a clean solution for presenting the "empty results" message with a transition?
(Resorting to a hacky workaround involves adding a dummy entry to the RESULTS
data and checking for it throughout.)