-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refs incorrect when using v-for and combining components and elements #5997
Comments
Cited from https://vuejs.org/v2/guide/components.html#Child-Component-Refs
I think you should not use it for dynamical referring to components. try to use |
That might have something to do with it. But in this case the |
You actually can call any function to generate a string for the Although somehow difficult, it is even possible to change that from the child component (add new data to parent and |
Version
2.3.4
Reproduction link
https://jsfiddle.net/floorish/7td2offb/
Steps to reproduce
ref
:<component :is="child.type" v-for="child in children" :key="child.id" ref="children"></component>
child.type
s where one of them uses a loading component:<loading v-if="isLoading"></loading> <div v-else>Child B ready</div>
isLoading
fromtrue
tofalse
after a timeout/async callWhat is expected?
parent.$refs.children
equals the displayed child componentsWhat is actually happening?
parent.$refs.children
only includes the child component that has the loading mechanismThis is very much an edge case, but it took me a while to figure out any solutions. Most trivial solution is to wrap the Child template in another
<div>
, but AFAIK the<div v-if="val"></div> <div v-else></div>
construct in the root of a template is supported in Vue (there is always a single root element).Other solutions are provided in reproduction link.
The text was updated successfully, but these errors were encountered: