can't access ref correctly if component was imported by defineAsyncComponent()
Version
3.0.3
Reproduction link
https://codepen.io/ShookLyngs/pen/gOwObGG
Steps to reproduce
- import component by using
defineAsyncComponent()
, for example componentitem
- define ref in template, for example
<item ref="item" />
- access ref in manual event callback, like
@click
- access funcion in component item
- using
this.$refs.item.do()
, fail - using
this.$refs.item.$refs.item.do()
, success
What is expected?
access ref by this.$refs.item
.
What is actually happening?
have to access ref by using this.$refs.item.$refs.item
.
Looks like the
ref
is pointing to the AsyncWrapper instead
Yes, and if I have a component item
, its content is simply:
<template>
<slot />
</template>
Then when I use this component,
and pass a async-component
to fill the slot:
<item>
<async-component />
</item>
In component item
, I tried to get this.$el
in mounted()
or in $nextTick()
, but it just won't work.
What can I do to get the content of component item
?