Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<template>
<ul>
<li
v-for="(name, i) in names"
:key="name"
:ref="el => elements[i] = el"
>
{{ name }}
</li>
</ul>
</template>
<script>
import { ref, onMounted } from 'vue'
export default {
setup () {
const names = ref(['Matt', 'John', 'Jane'])
const elements = ref([])
onMounted(() => {
console.log(elements.value) // [li, li ,li]
})
return {
names,
elements
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment