Template Refs in v-for not working
See original GitHub issueVersion
3.2.31
Reproduction link
Steps to reproduce
Open the DevTools and look at the console.logs from onMounted
.
You now see three logs, each representing a different template Ref.
Log one and three are a single template ref and an array filled with function refs. They are working fine as expected.
The issue is that the second ref is not returning an array of elements from the v-for
but stays empty as initialized.
What is expected?
Template Ref on the v-for
should be a DOM NodeList or an Array of DOMElements
What is actually happening?
The initialized ref([])
stays empty
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:24 (10 by maintainers)
Top Results From Across the Web
Vue.js ref inside the v-for loop - Stack Overflow
When using refs with v-for, the component / DOM nodes are stored as an array directly to the variable name so you don't...
Read more >Template Refs - Vue.js
ref is a special attribute, similar to the key attribute discussed in the v-for chapter. It allows us to obtain a direct reference...
Read more >The Beginners Guide to Template Refs - LearnVue
In this tutorial, we'll be learning all about template refs: how to use them in both the Options API and Composition API, some...
Read more >Understanding refs in Vue - LogRocket Blog
Verify your version by running node -v in your terminal/command ... On template inspection in your browser, $refs do not show up at...
Read more >How to use $refs in Vue 3 with Composition API and Script ...
It is important to clarify that refs should not be used unless strictly ... Let's write two simple example, for the Composition API...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@LinusBorg ignore this
The PR does indeed fix this issue for dev mode!
A possible workaround for the current limitation is:
https://stackblitz.com/edit/vitejs-vite-jfeskg?file=src/App.vue
Workaround works 👍🏼 Looking forward to bug fix. Tx