0👍
Using the ref turns list
into reactive variable. Whenever new item is appended or it is otherwise mutated, the other functions or template parts watching it get updated. In your example without ref, when you append a new item to the list, it won’t be automatically rendered in the template.
I can understand your confusion and I assume you probably come from vue2 world. I can’t recommend enough reading vue3 docs about reactivity.
0👍
These are two different types of refs:
itemRefs
is an array of template ref. It’s a reference to an html element / vue component from your component template. It’s associated to theref
attribute on the element.list
is a "regular" ref. It adds reactivity over the array of values. Without it, Vue won’t react to the value changes and won’t update the rendered component.
- [Vuejs]-How to properly upload file from vue to laravel?
- [Vuejs]-Vue3 / Nuxt3 – how to use props directly in setup
Source:stackexchange.com