File tree Expand file tree Collapse file tree 1 file changed +38
-25
lines changed Expand file tree Collapse file tree 1 file changed +38
-25
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ Vue.js wrapper for SweetAlert2. With support SSR.
14
14
15
15
## Get started
16
16
17
-
17
+ ### Basics
18
18
``` bash
19
19
npm install -S vue-sweetalert2
20
20
```
@@ -31,9 +31,32 @@ import 'sweetalert2/dist/sweetalert2.min.css';
31
31
Vue .use (VueSweetalert2);
32
32
```
33
33
34
-
35
34
Now in the global object, you can access all the methods of [ sweetalert2] ( https://github.com/limonte/sweetalert2 ) .
36
35
36
+ ``` html
37
+ // example-vue-component.vue
38
+ <template >
39
+ <button @click =" showAlert" >Hello world</button >
40
+ </template >
41
+
42
+ <script >
43
+ export default {
44
+ methods: {
45
+ showAlert (){
46
+ // Use sweetalert2
47
+ this .$swal (' Hello Vue world!!!' );
48
+ }
49
+ }
50
+ }
51
+ </script >
52
+ ```
53
+
54
+ // Or
55
+ ``` js
56
+ Vue .swal (' Hello Vue world!!!' );
57
+ ```
58
+
59
+ ### Global options
37
60
If you want to add global options like button colors, do something like this:
38
61
``` js
39
62
// main.js
@@ -47,8 +70,20 @@ const options = {
47
70
48
71
Vue .use (VueSweetalert2, options)
49
72
```
50
-
73
+ ### Custom styling
51
74
Using scss styles are loaded so
75
+ ``` js
76
+ // main.js
77
+ import Vue from ' vue' ;
78
+ import VueSweetalert2 from ' vue-sweetalert2' ;
79
+
80
+ const options = {
81
+ includeCss: false
82
+ }
83
+
84
+ Vue .use (VueSweetalert2, options)
85
+ ```
86
+
52
87
``` scss
53
88
// style.scss
54
89
@import ' ~sweetalert2/src/variables' ;
@@ -61,28 +96,6 @@ $swal2-background: #990000;
61
96
62
97
63
98
64
- ``` html
65
- // example-vue-component.vue
66
- <template >
67
- <button @click =" showAlert" >Hello world</button >
68
- </template >
69
-
70
- <script >
71
- export default {
72
- methods: {
73
- showAlert (){
74
- // Use sweetalert2
75
- this .$swal (' Hello Vue world!!!' );
76
- }
77
- }
78
- }
79
- </script >
80
- ```
81
-
82
- // Or
83
- ``` js
84
- Vue .swal (' Hello Vue world!!!' );
85
- ```
86
99
87
100
## Nuxt.js
88
101
You can’t perform that action at this time.
0 commit comments