rlemaigre / vue3-promise-dialog Goto Github PK
View Code? Open in Web Editor NEWDialogs meet promises in Vue 3 !
License: MIT License
Dialogs meet promises in Vue 3 !
License: MIT License
Installed vue3-promise-dialog in existing webpack/typescript vue app, PromiseDialog is imported fine but there doesn't appear to be a DialogWrapper component exported (at least as far as typescript knows).
import { DialogWrapper } from 'vue3-promise-dialog';
Currently it seems the only way to dismiss a dialog, is to use the $close
function from the template. (Possibly, you could also do this.$close
from the Options API?)
Is there any way to dismiss dialogs from within setup()? My first hunch was to try import { closeDialog } from 'vue3-promise-dialog';
, but it seems the closeDialog
isn't exported.
I tried also the following workaround in my dialog component, but it throws an error when used:
const instance = getCurrentInstance();
onMounted(() => {
setBackAction(instance?.appContext.config.globalProperties.$close);
})
Error:
Uncaught TypeError: comp.returnValue is not a function
at Proxy.app.config.globalProperties.$close (vue3-promise-dialog.es.js?db71:23:1)
at eval (MessengerHeader.vue?a0c7:54:1)
at eval (runtime-dom.esm-bundler.js?2725:1466:1)
at callWithErrorHandling (runtime-core.esm-bundler.js?d2dd:155:1)
at callWithAsyncErrorHandling (runtime-core.esm-bundler.js?d2dd:164:1)
at HTMLAnchorElement.invoker (runtime-dom.esm-bundler.js?2725:366:1)
Hello,
Can this library open nested dialog box?
Thanks,
Everything works great, but vs-code tells me that it can't find function $close. From where should I find it's declaration? Or maybe there is some workaround to just hide the error?
Hi there โ
I'm trying to implement a basic dialog using the Composition API, in plain JS.
My component is shown below (styles omitted):
<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';
}
</script>
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:
runtime-core.esm-bundler.js:218 Uncaught TypeError: dialogRef.value.comp.returnValue is not a function
at closeDialog (vue3-promise-dialog.es.js:5:33)
at Proxy.app.config.globalProperties.$close (vue3-promise-dialog.es.js:23:7)
at _createElementVNode.onClick._cache.<computed>._cache.<computed> (TempDialog.vue:6:23)
at callWithErrorHandling (runtime-core.esm-bundler.js:155:22)
at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:164:21)
at HTMLButtonElement.invoker (runtime-dom.esm-bundler.js:366:13)
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!
Hi
Using Typescript, with Vite 3.x, Vue 3.x
I get a build error:
src/main.ts:48:10 - error TS2345: Argument of type '{ install: (app: any, options: any) => void; }' is not assignable to parameter of type 'Plugin_2<[]>'.
Type '{ install: (app: any, options: any) => void; }' is not assignable to type '{ install: (app: App<any>) => any; }'.
Types of property 'install' are incompatible.
Type '(app: any, options: any) => void' is not assignable to type '(app: App<any>) => any'.
48 .use(PromiseDialog)
If using <script setup> it is necessary to expose the returnValue function in the following way. (It took me a while to figure this out; perhaps the README can be updated)
defineExpose({
returnValue: () => { return true },
});
Sorry for asking such a potentially rude question...
But is there any alternative library which serves the same purpose but is actively maintained?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.