admin管理员组文章数量:1392003
When I try to get the ref of my custom ponents it results in:
Proxy {__v_skip: true}
[[Handler]]: Object
[[Target]]: Proxy
[[IsRevoked]]: false
but works just fine when replacing d-icon-button
with a div
tag
Here is a quick example that returns the console log from above:
<template>
<d-icon-button ref="button">
...
</d-icon-button>
</template>
<script lang="ts" setup>
/* imports ... */
const button = ref(null);
onMounted(()=>{
console.log(button.value)
})
And here is the d-icon-button
ponent itself: vuelize -> d-icon-button
I think it has something to do with the wrapper I use in every ponent, but that's all I know so far
When I try to get the ref of my custom ponents it results in:
Proxy {__v_skip: true}
[[Handler]]: Object
[[Target]]: Proxy
[[IsRevoked]]: false
but works just fine when replacing d-icon-button
with a div
tag
Here is a quick example that returns the console log from above:
<template>
<d-icon-button ref="button">
...
</d-icon-button>
</template>
<script lang="ts" setup>
/* imports ... */
const button = ref(null);
onMounted(()=>{
console.log(button.value)
})
And here is the d-icon-button
ponent itself: vuelize -> d-icon-button
I think it has something to do with the wrapper I use in every ponent, but that's all I know so far
Share Improve this question asked Sep 9, 2022 at 21:48 Daniel TerletzkiyDaniel Terletzkiy 793 silver badges5 bronze badges1 Answer
Reset to default 5I think this answer might be related to your issue.
You have to expose refs from ponents because they are "closed" by default: https://vuejs/api/sfc-script-setup.html#defineexpose
本文标签: javascriptHow to use a template ref on a custom component in vue 3 compositon apiStack Overflow
版权声明:本文标题:javascript - How to use a template ref on a custom component in vue 3 compositon api - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744760311a2623715.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论