the div which has the ref attribute inside the v-for, when I v-if toggle them, the ref value.length increase more and more
Vue version
3.2.47
Link to minimal reproduction
Steps to reproduce
if I click toggleVisible
many times,
- the
refDivSingle
toggle between null and div - the
refCompSingle
toggle between null and {} - the
refDivArr.length
increase more and more <-- error here - the
refCompArr.length
toggle between 3 and 0
if I use ref function, it don't get null
What is expected?
the refDivArr.length
should toggle between 3 and 0, same as the refCompArr.length
What is actually happening?
the refDivArr.length
increase more and more
System Info
No response
Any additional comments?
No response
a workaround:
<div v-for="(vv0, index0) in 3" :key="index0" ref="refDivArr">
+<div v-for="(vv0, index0) in 3" ref="refDivArr">
<CompB ref="refCompArr"></CompB>
</div>
If I use ref function, it can not get null
, when bind to DIV
@Alfred-Skyblue @edison1105