Jenesius Vue Modal
Jenesius vue modal is simple modal system library for Vue 3 only .
Using this library, you can simply show both one and several modal windows at the same time, integrate with vue-router
Installation
For add modals in your project you need to put the modal's container where in the App(root) component:
App.vue
Modal show
Methods openModal
and pushModal
used to display modal windows.
openModal
- close all previous modals and then display provided component.pushModal
- display provided component
- props will provide in your component, example
Methods return promise, in this case promise is resolved modalObject.
More information
Methods
openModal
- close all modals and then open provided modal.pushModal
- add one more provided modal.closeModal
- close all modals.popModal
- close last opened modal.
Handle events
Using modalObject you can handle any events:
When we click on the button we can handle event using modal.on(eventName, callback)
Lifecycle Hooks
All hooks use only returned value(Boolean) for navigation hooks.
If function return false or throwing an Error modal window will not be closed.
There are three ways to track the closing of a modal:
- onclose
or if using function declaration you have access to modal Instance by this.
This declaration provide way to view data within the modal in the parent's onclose() method:
- default component
- Composition style
Async/Await
Hooks also can be asynchronous functions:
or
Integration with VueRouter
For integrate modals into VueRouter you need to initialize your application:
- Provide router to the useModalRouter:
- Wrap your component in a route handler:
Now, when route will be /any-route the Modal window will open.
For more information see Docs.
Style and Animation
Please refer to the documentation to change the styles or animations of modals.
Example VueModalComponent
WidgeTestModal.vue
To show this component