Skip to content

'Duplicate keys detected: ...' error with same keyed children inside a v-fored template #7323

Closed
@mathieumure

Description

@mathieumure

Version

2.5.13

Reproduction link

https://jsfiddle.net/56zfwbe5/1/

Steps to reproduce

  • Open the jsfiddle demo
  • Open your console
  • Run the demo
  • now you should see an error like this: [Vue warn]: Duplicate keys detected:

What is expected?

Children inside a repeated <template> should share the same keys as they should both re-render if the target element changes.

What is actually happening?

Errors are raised with the message : [Vue warn]: Duplicate keys detected is raised.


Cause

This behavior is linked to this PR and was also references in this issue

Workaround

You could avoid this error by adding some prefix / suffix

<template v-for="it in items">
    <li :key="it.id + '-label'">{{it.label}}</li>
    <li :key="it.id + '-separator'" class="separator">&gt;</li>
</template>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions