3
3
<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 >
4
4
5
5
<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 >
9
7
<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 >
10
8
<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 >
11
9
</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 >
12
18
13
19
<p align =" right " >
14
20
<a href =" https://www.buymeacoffee.com/PL2qJIx " target =" _blank " rel =" noopener noreferrer " >
@@ -71,55 +77,39 @@ Yarn:
71
77
yarn add vue-final-modal
72
78
```
73
79
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
91
81
92
- - ** Install globally **
82
+ ### Vue
93
83
94
84
``` js
95
- import { VueFinalModal } from ' vue-final-modal'
85
+ import VueFinalModal from ' vue-final-modal'
96
86
97
- Vue .component ( ' VueFinalModal ' , VueFinalModal)
87
+ Vue .use ( VueFinalModal)
98
88
```
99
89
100
- #### Nuxt
90
+ ### Nuxt
101
91
102
92
- ** Write a plugin ` vue-final-modal.js ` **
103
93
104
94
``` js
105
95
// plugins/vue-final-modal.js
106
- import VueFinalModal from ' vue-final-modal/lib/VueFinalModal.vue '
96
+ import VueFinalModal from ' vue-final-modal/lib'
107
97
108
- Vue .component ( ' VueFinalModal ' , VueFinalModal)
98
+ Vue .use ( VueFinalModal)
109
99
```
110
100
111
101
- ** Add plugin into ` nuxt.config.js ` **
112
102
113
103
``` js
114
104
// nuxt.config.js
115
105
export default {
116
- plugins: [
117
- ' ~plugins/vue-final-modal.js'
118
- ],
106
+ plugins: [' ~plugins/vue-final-modal.js' ]
119
107
}
120
108
```
121
109
122
- #### CDN
110
+ ### CDN
111
+
112
+ > [ Live demo] ( https://codepen.io/hunterliu1003/pen/ZEWoYeE )
123
113
124
114
- ** jsDelivr**
125
115
@@ -133,21 +123,114 @@ export default {
133
123
<script src =" https://unpkg.com/vue-final-modal" ></script >
134
124
```
135
125
136
- ### ** Add component to template**
126
+ ## Basic usage
127
+
128
+ ### ** Click button to open modal**
137
129
138
130
``` html
139
131
<vue-final-modal v-model =" showModal" >
140
132
Modal Content Here
141
133
</vue-final-modal >
134
+
135
+ <button @click =" showModal = true" >Launch</button >
142
136
```
143
137
144
- ### ** Create a button **
138
+ ### ** Open modal with API **
145
139
146
140
``` 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' )
148
148
```
149
149
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**
151
234
152
235
``` js
153
236
const CLASS_TYPES = [String , Object , Array ]
@@ -184,11 +267,11 @@ const CLASS_TYPES = [String, Object, Array]
184
267
185
268
### ` @opened `
186
269
187
- - Emits after modal became visible and transition ended.
270
+ - Emits after modal became visible and transition ended.
188
271
189
272
### ` @before-close `
190
273
191
- - Emits before modal is going to be closed.
274
+ - Emits before modal is going to be closed.
192
275
193
276
### ` @closed `
194
277
0 commit comments