Access ref from slot in my component #14342
Unanswered
gimler
asked this question in
Help/Questions
Replies: 1 comment
-
|
Use Incomplete code snippet using // MyComponent.vue
<script setup>
const child = ref(), btn = ref();
provide('M',reactive({ child, btn }));
</script>// MyBtn.vue
<script setup>
const onClick = () => { }
const M = inject('M') || {};
watchEffect(()=>{ M.btn = { onClick } })
</script>You can even use HTML |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a component that defines a slot.
When i use this component i define a ref on a child component in the default slot
i always getting
null. The form ref works.I found this hack
Why
I need to call a method from
my-child(use defineExpose) when clicking onmy-btn.Question:
Is there a better way to access the ref in the slot?
Beta Was this translation helpful? Give feedback.
All reactions