-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nested v-for by component and template bug #3810
Comments
It actually works when <template v-for="toy in child.toys">
<template v-if="toy.name == 'b'" :key="toy.id">
<p>toy a</p>
</template>
<template v-else :key="toy.id">
<p>toy b</p>
</template>
</template> https://codepen.io/fnlctrl/pen/XjaXPa?editors=1011 It also works when the inner <template v-for="toy in child.toys">
<div v-if="toy.name == 'b'" :key="toy.id">
<p>toy a</p>
</div>
<div v-if="toy.name != 'b'" :key="toy.id">
<p>toy b</p>
</div>
</template> https://codepen.io/fnlctrl/pen/jrLWQq?editors=1011 And it works when the outer <div v-for="toy in child.toys">
<template v-if="toy.name == 'b'" :key="toy.id">
<p>toy a</p>
</template>
<template v-if="toy.name != 'b'" :key="toy.id">
<p>toy b</p>
</template>
</div> https://codepen.io/fnlctrl/pen/KgvVJg?editors=1111 So I guess it's using multiple |
yes, u r right. |
thank you~ |
with two keyed children inside <div v-for="toy in child.toys">
<div :key="toy.id"> </div>
<div :key="toy.id"> </div>
</div> in order to avoid that we need to add some thing to that keys <div v-for="toy in child.toys">
<div :key="toy.id + '-first'"> </div>
<div :key="toy.id + '-second'"> </div>
</div> |
Vue.js version
2.0-rc8 / 2.0-rc7
Reproduction Link
https://codepen.io/toxic-johann/pen/JRJgGJ?editors=1111
Steps to reproduce
use a v-for to render component
in component, you have to write a v-for with template in it but not wrapped with a root element
open console, and run test() function
What is Expected?
open console, and run success() function
or you can click https://codepen.io/toxic-johann/pen/JRJgGJ?editors=1111.
when i keep on one root element in v-for, the problem dispear.
So I think, if vue consider multiple element int the template is forbidden.It should throw a warn.
Otherwise, it's a bug
What is actually happening?
throw the warning
it's the same problem with #3807
u can reopen that.
The text was updated successfully, but these errors were encountered: