vue-final / vue-final-modal

🍕Vue Final Modal is a tiny, renderless, mobile-friendly, feature-rich modal component for Vue.js.
https://vue-final-modal.org
MIT License
903 stars 97 forks source link

Why do dynamic modals no longer exist in v4 (options API) #343

Closed noook closed 10 months ago

noook commented 1 year ago

Version

vue-final-modal: 4.0.11 vue: 3.2 nuxt: 3.2.3

Question

We are migrating from vue-js-modal where all of our modals were created dynamically. We are migrating from a Nuxt 2 to a Nuxt 3 project, so most of our code is written in Options API, so using a setup in order to use useModal() cannot work as setup is invoked before the other hooks and won't be able to refer to the component's data.

I was wondering if there is still any way to create the modals dynamically in the options API, and if so, how ?

If not, do you plan to reintroduce this feature ?

samb1999 commented 11 months ago

+1

hunterliu1003 commented 10 months ago

@noook @samb1999 You can still use useModal() to replace all of the dynamic modals by using options API. useModal() is allowed to be used in both setup script and Options API. Here is an example that use Nuxt 3 and Options API: https://stackblitz.com/edit/github-1brl3g?file=components%2FMyModalPreview.vue