Subscribe on changes!

Template ref array gets children in onmounted, which is empty

avatar
Aug 7th 2022

Vue version

3.2.37

Link to minimal reproduction

Steps to reproduce

<script setup>
import { ref,onMounted } from 'vue'

onMounted(()=>{
  console.log("got zero",itemsRef.length)
})
const itemsRef = []
const setItemsRef = (el)=>{
  if(el){
    itemsRef.push(el)
  }
}
</script>

<template>

  <div v-for="item in 10" :ref="setItemsRef">{{item}}</div>
</template>

What is expected?

The DOM structure in onMounted that operates on the ref array

What is actually happening?

The SFC Playground Cannot be reproduced.

This also occurs in the component's < slot > , where the child component can not manipulate the DOM in the slot from onMounted

System Info

No response

Any additional comments?

No response

avatar
Aug 7th 2022

If you cant repeoduce the problem, we cant either.

Feel free to share a github repo with a minima reproduction if the playground doesn't work for you.