Skip to content

ref doesn't work properly with v-for together #1166

Closed
@Jinjiang

Description

@Jinjiang

Version

3.0.0-beta.10

Reproduction link

https://codesandbox.io/s/goofy-yalow-d0x6e?file=/src/App.vue

Steps to reproduce

<template>
  <span v-for="n in 10" ref="x">{{ n }}</span>
</template>

<script>
export default {
  mounted() {
    console.log(this.$refs.x);
  }
}
</script>

What is expected?

print an array of all spans

What is actually happening?

the last span


https://vuejs.org/v2/api/#ref

When used on elements/components with v-for, the registered reference will be an Array containing DOM nodes or component instances.

Metadata

Metadata

Assignees

No one assigned

    Labels

    has workaroundA workaround has been found to avoid the problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions