Closed ocratravis closed 2 years ago
I don't use script setup myself (yet) so I never tried this package with it. Have you tried to explicitly expose the returnValue function using defineExpose ? See docs here : https://vuejs.org/api/sfc-script-setup.html#defineexpose
Please tell me if it works. If it does, I'll update the docs accordingly.
Thanks for the reply. I will test this ASAP and let you know.
That did the trick! The following code works:
<template>
<div class="dialog">
<div class="center">
<p>{{text}}</p>
<button @click="$close(this, 'user clicked no')" class="btn">NO</button>
<button @click="$close(this)" class="btn">YES</button>
</div>
</div>
</template>
<script setup>
const props = defineProps({
text: {
type: String,
},
})
function returnValue() {
return 'user clicked yes';
}
defineExpose({
returnValue,
})
</script>
Thank you!
Hi there –
I'm trying to implement a basic dialog using the Composition API, in plain JS.
My component is shown below (styles omitted):
This almost works. Clicking on "No" resolves the promise with the string "user clicked no", as expected.
However, clicking on "Yes" gives the following error in the console:
Do you know what I'm doing wrong? I'm sure it's something basic...
It would be nice to provide an example of this usage in the docs.
Thanks for this great package – if I can figure out this little detail, then it's exactly what I needed!