Skip to content

v-else and v-once on custom component inside v-for #4182

@fmairesse

Description

@fmairesse

Here is a list rendering using a custom component and the v-once directive:

<li v-for="item of items" :key="item.model.id">
    <item :model="item.model" v-once></item>
</li>

JsFiddle using [email protected]
Note that this does not work using [email protected], unless we remove the v-once directive.

Now let's add a conditional rendering:

  <li v-for="item of items" :key="item.model.id">
    <span v-if="item.model.id===1">BOB</span>
    <item :model="item.model" v-else v-once></item>
  </li>

JsFiddle using [email protected]
JsFiddle using [email protected]
This fails using [email protected] with the error:

Property or method "item" is not defined on the instance but referenced during render.

but works with 2.0.3 (2.0.3 failed when there was no v-else)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions