avil13 / vue-sweetalert2

A convenient wrapper for sweetalert2.
https://avil13.github.io/vue-sweetalert2/
655 stars 75 forks source link

Example for using Sweetalert2 In Vue3: Composition API #126

Closed microchi closed 3 years ago

microchi commented 3 years ago

Dear @avil13

https://codesandbox.io/s/sweetalert2-vue3-jdrjc

It is a Example for calling sweetalert2 directly in Vue3 Composion API with inject.

Please use the example in readme.

Thank You~

avil13 commented 3 years ago

@microchi thank you very much for the example. What do you think about the fact that it is only for vue 3? I wanted to be able to use the same library for both versions of Vue.

avil13 commented 3 years ago

Maybe split up into different modules?

avil13 commented 3 years ago

@microchi Thanks for the great example for working with the Composition API.

But it seems to me that if you use it, it would be an unnecessary wrapper. You can do a direct import from sweetalert2 library.

import Swal from "sweetalert2";

That would save you the trouble of updating and transpiling.

The current implementation, is more suitable for an older version of Vue. Optional Components. You don't need to do additional imports.

I hope I managed to get my point across. If you agree, I suggest we close this issue.

microchi commented 3 years ago

Dear @avil13

Ok!

How about adding a useVueSweetAlert2 function or jnject directly? There will be "When using "Vue3: Composition API" it is STILL to use this wrapper." And maybe modify readme for the people who use composition api.

Please visit the code sandbox. It implement both! https://codesandbox.io/s/vuesweetalert2-composition-api-1v3y7?file=/src/components/HelloWorld.vue

ps.

The images in readme are better using full path. It broken on github first page. https://raw.githubusercontent.com/avil13/vue-sweetalert2/master/packages/vue-sweetalert2/assets/logo.png https://raw.githubusercontent.com/avil13/vue-sweetalert2/master/packages/vue-sweetalert2/assets/vue-sweetalert2.gif image

microchi commented 3 years ago

Ok! Please Close This Issue

ps-leocxy commented 11 months ago

@microchi Thanks for the great example for working with the Composition API.

But it seems to me that if you use it, it would be an unnecessary wrapper. You can do a direct import from sweetalert2 library.

import Swal from "sweetalert2";

That would save you the trouble of updating and transpiling.

The current implementation, is more suitable for an older version of Vue. Optional Components. You don't need to do additional imports.

I hope I managed to get my point across. If you agree, I suggest we close this issue.

You are right. I can import the sweetalert2 from the component directly. That is very helpful.