-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Closed
Labels
Description
Version
3.2.29
Reproduction link
Steps to reproduce
Open the reproduction code.
What is expected?
Code should compile and transitions should work fluently when clicking the buttons.
What is actually happening?
It will not compile because of the key
property on the group headings:
SyntaxError: <template v-for> key should be placed on the <template> tag.
App.vue
19 | <transition-group name="cell" tag="div" class="grid">
20 | <template v-for="group in groups" :key="group.id">
21 | <h2 :key="`title-${group.id}`">{{ group.name }}</h2>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
22 | <div v-for="letter in group.letters" :key="letter">{{ letter }}</div>
23 | </template>
Removing the key will throw a warning:
at <TransitionGroupname="cell"tag="div"class="grid">
This warning is correct, because without a key the transitions will not work as expected when adding or removing items from the groups
array.
There are a couple of similar issues (#4718, #5152), but they are not duplicates of this one since they are focusing on the warning when a key is not used. But in this case, a key is needed but the code won't compile, even though it is valid code.