33<p align =" center " ><a href =" https://vue-final-modal.org " target =" _blank " rel =" noopener noreferrer " ><img src =" https://vue-final-modal.org/preview.png " alt =" Vue Final Modal Logo " ></a ></p >
44
55<p align =" center " >
6- <a href =" https://npmcharts.com/compare/vue-final-modal?minimal=true " ><img src =" https://img.shields.io/npm/dm/vue-final-modal.svg?sanitize=true " alt =" Downloads " ></a >
7- <a href =" https://www.npmjs.com/package/vue-final-modal " ><img src =" https://badgen.net/bundlephobia/minzip/vue-final-modal " alt =" Size " ></a >
8- <a href =" https://www.npmjs.com/package/vue-final-modal " ><img src =" https://img.shields.io/npm/v/vue-final-modal.svg?sanitize=true " alt =" Version " ></a >
6+ <a href =" https://npmcharts.com/compare/vue-final-modal?minimal=true " ><img src =" https://badgen.net/npm/dm/vue-final-modal " alt =" Downloads " ></a >
97 <a href =" https://www.npmjs.com/package/vue-final-modal " ><img src =" https://img.shields.io/npm/l/vue-final-modal.svg?sanitize=true " alt =" License " ></a >
108 <a href =" https://app.netlify.com/sites/vue-final-modal/deploys " ><img src =" https://api.netlify.com/api/v1/badges/444b13a8-540f-4438-94da-80c865c8f103/deploy-status " alt =" Netlify Status " ></a >
119</p >
10+ <p align =" center " >
11+ <a href =" https://www.npmjs.com/package/vue-final-modal " ><img src =" https://badgen.net/npm/v/vue-final-modal " alt =" Version " ></a >
12+ <a href =" https://www.npmjs.com/package/vue-final-modal " ><img src =" https://badgen.net/badgesize/brotli/hunterliu1003/vue-final-modal/master/dist/VueFinalModal.umd.js " alt =" Size " ></a >
13+ </p >
14+ <p align =" center " >
15+ <a href =" https://www.npmjs.com/package/vue-final-modal " ><img src =" https://badgen.net/npm/v/vue-final-modal/next " alt =" Version " ></a >
16+ <a href =" https://www.npmjs.com/package/vue-final-modal " ><img src =" https://badgen.net/badgesize/brotli/hunterliu1003/vue-final-modal/next/dist/VueFinalModal.umd.js " alt =" Size " ></a >
17+ </p >
1218
1319<p align =" right " >
1420 <a href =" https://www.buymeacoffee.com/PL2qJIx " target =" _blank " rel =" noopener noreferrer " >
@@ -71,55 +77,39 @@ Yarn:
7177yarn add vue-final-modal
7278```
7379
74- ## Basic usage
75-
76- ### Register
77-
78- #### Vue
79-
80- - ** Register in SFC**
81-
82- ``` js
83- import { VueFinalModal } from ' vue-final-modal'
84-
85- export default {
86- components: {
87- VueFinalModal
88- }
89- }
90- ```
80+ ## Registeration
9181
92- - ** Install globally **
82+ ### Vue
9383
9484``` js
95- import { VueFinalModal } from ' vue-final-modal'
85+ import VueFinalModal from ' vue-final-modal'
9686
97- Vue .component ( ' VueFinalModal ' , VueFinalModal)
87+ Vue .use ( VueFinalModal)
9888```
9989
100- #### Nuxt
90+ ### Nuxt
10191
10292- ** Write a plugin ` vue-final-modal.js ` **
10393
10494``` js
10595// plugins/vue-final-modal.js
106- import VueFinalModal from ' vue-final-modal/lib/VueFinalModal.vue '
96+ import VueFinalModal from ' vue-final-modal/lib'
10797
108- Vue .component ( ' VueFinalModal ' , VueFinalModal)
98+ Vue .use ( VueFinalModal)
10999```
110100
111101- ** Add plugin into ` nuxt.config.js ` **
112102
113103``` js
114104// nuxt.config.js
115105export default {
116- plugins: [
117- ' ~plugins/vue-final-modal.js'
118- ],
106+ plugins: [' ~plugins/vue-final-modal.js' ]
119107}
120108```
121109
122- #### CDN
110+ ### CDN
111+
112+ > [ Live demo] ( https://codepen.io/hunterliu1003/pen/ZEWoYeE )
123113
124114- ** jsDelivr**
125115
@@ -133,21 +123,114 @@ export default {
133123<script src =" https://unpkg.com/vue-final-modal" ></script >
134124```
135125
136- ### ** Add component to template**
126+ ## Basic usage
127+
128+ ### ** Click button to open modal**
137129
138130``` html
139131<vue-final-modal v-model =" showModal" >
140132 Modal Content Here
141133</vue-final-modal >
134+
135+ <button @click =" showModal = true" >Launch</button >
142136```
143137
144- ### ** Create a button **
138+ ### ** Open modal with API **
145139
146140``` html
147- <button @click =" showModal = true" >Launch</button >
141+ <vue-final-modal v-model =" showModal" name =" example" >
142+ Modal Content Here
143+ </vue-final-modal >
144+ ```
145+
146+ ``` js
147+ this .$vfm .show (' example' )
148148```
149149
150- ### ** Default props**
150+ ## ** API**
151+
152+ Plugin API can be called within any component through ` this.$vfm ` .
153+
154+ ### ` $vfm.openedModals `
155+
156+ - Type: ` Array `
157+
158+ A stack array store the opened modal's vue component instance.
159+
160+ You can use:
161+ 1 . ` $vfm.openedModals[0] ` to get the first opened modal instance.
162+ 2 . ` $vfm.openedModals.length ` to get how many modals is opened.
163+
164+ ### ` $vfm.modals `
165+
166+ - Type: ` Array `
167+
168+ All modal instances include show and hide.
169+
170+ ### ` $vfm.show(name) `
171+
172+ - Type: ` Function `
173+ - Arguments:
174+ - name: ` String ` - Name of the modal
175+ - Example:
176+
177+ ``` html
178+ <template >
179+ <vue-final-modal v-model =" show" name =" example" >Vue Final Modal is awesome</vue-final-modal >
180+ </template >
181+
182+ <script >
183+ export default {
184+ name: ' MyComponent' ,
185+ data : () => ({
186+ show: false
187+ }),
188+ mounted () {
189+ this .$modal .show (' example' )
190+ }
191+ }
192+ </script >
193+ ```
194+
195+ ### ` $vfm.hide(name) `
196+
197+ - Type: ` Function `
198+ - Arguments:
199+ - name: ` String ` - Name of the modal
200+ - Example:
201+
202+ ``` html
203+ <template >
204+ <vue-final-modal v-model =" show" name =" example" >Vue Final Modal is awesome</vue-final-modal >
205+ </template >
206+
207+ <script >
208+ export default {
209+ name: ' MyComponent' ,
210+ data : () => ({
211+ show: true
212+ }),
213+ mounted () {
214+ this .$modal .hide (' example' )
215+ }
216+ }
217+ </script >
218+ ```
219+
220+ ### ` $vfm.hideAll() `
221+
222+ hide all modals.
223+
224+ ### ` $vfm.toggle(name, show) `
225+
226+ - Type: ` Function `
227+ - Arguments:
228+ - name: ` String ` - Name of the modal
229+ - show: ` Boolean ` - Show modal or not
230+
231+ toggle modal by name.
232+
233+ ## ** Props**
151234
152235``` js
153236const CLASS_TYPES = [String , Object , Array ]
@@ -184,11 +267,11 @@ const CLASS_TYPES = [String, Object, Array]
184267
185268### ` @opened `
186269
187- - Emits after modal became visible and transition ended.
270+ - Emits after modal became visible and transition ended.
188271
189272### ` @before-close `
190273
191- - Emits before modal is going to be closed.
274+ - Emits before modal is going to be closed.
192275
193276### ` @closed `
194277
0 commit comments