Skip to content

Commit a6ab89d

Browse files
authored
Merge pull request #63 from vincentdh/master
Reformatted the instructions
2 parents da55499 + 7925059 commit a6ab89d

File tree

1 file changed

+38
-25
lines changed

1 file changed

+38
-25
lines changed

README.md

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Vue.js wrapper for SweetAlert2. With support SSR.
1414

1515
## Get started
1616

17-
17+
### Basics
1818
```bash
1919
npm install -S vue-sweetalert2
2020
```
@@ -31,9 +31,32 @@ import 'sweetalert2/dist/sweetalert2.min.css';
3131
Vue.use(VueSweetalert2);
3232
```
3333

34-
3534
Now in the global object, you can access all the methods of [sweetalert2](https://github.com/limonte/sweetalert2).
3635

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
3760
If you want to add global options like button colors, do something like this:
3861
```js
3962
// main.js
@@ -47,8 +70,20 @@ const options = {
4770

4871
Vue.use(VueSweetalert2, options)
4972
```
50-
73+
### Custom styling
5174
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+
5287
```scss
5388
// style.scss
5489
@import '~sweetalert2/src/variables';
@@ -61,28 +96,6 @@ $swal2-background: #990000;
6196

6297

6398

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-
```
8699

87100
## Nuxt.js
88101

0 commit comments

Comments
 (0)