Skip to content

How to extract a TemplatePromise in another component #3032

Answered by antfu
antoniogiroz asked this question in Q&A
Discussion options

You must be logged in to vote

You could do:

// Foo.vue
<script setup>

const TemplatePromise = createTemplatePromise()

defineExpose({
  start: () => TemplatePromise.start()
})
</script>

And then

<script setup>
const el = ref()

function call() {
  el.value?.start()
}
</script>

<template>
  <Foo ref="el"/>
</template>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@antoniogiroz
Comment options

Answer selected by antoniogiroz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants