-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.md.bak
93 lines (66 loc) · 2.17 KB
/
README.md.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Vue-Easy-Alert
![Vue 2.x](https://img.shields.io/badge/vue-2.x-green.svg "Vue 2 Compatible")
A alert plugin for vue2.
[DEMO](https://github.com/ae86jung/vue2-easy-alert/example/index.html)
**Note:**
Issue/PR is welcomed, I'll response as soon as possible.
## Usage
#### install
`npm install vue-easy-alert-wangzhy --save`
#### Quickstart
```javascript
// before start
import Alert from 'vue-easy-alert-wangzhy'
Vue.use(Alert)
// in your code
Vue.alert('Can I have everybody`s attention?')
// or
$vm.$alert('Let me give a toast to you all.')
```
#### More
`alert` or `$alert` takes 2 parameter: `(message, [options])`
##### Options
Parameter | Type |Default| Description
--------- | ---- | ------|-----------
id | `string` | `easy-alert-default` | Unique identifier globally. Use this to create multiple toasts with different setups.
parent | `string`| `body` | Selector of the container (TODO, not ready yet, position is fixed to the window)
title | `string` | | Self-defined title to pass through.
titleStyle | `string` | | You can custom title properties here.
isConfirm | `boolean` | `false` | You can open the function of confirm here.
isAsync | `boolean` | `false` | If the request is asynchronous when you click the OK button,you can set this true.This property only applies when `isConfirm` is true.
onOk | `function` | | When you click the Ok button, this function will be called.If the `isAsync` is true, this function has a parameter `success`.You can call `success` when the asynchronous request is success.
##### example
```javascript
//Simplest alert
$vm.$alert(this.message);
//alert with title and custom the title style
$vm.$alert(this.message, {
title: '提醒',
titleStyle: 'color:red;'
});
//cofirm with title
$vm.$alert(this.message, {
title: '提醒',
titleStyle: 'color:red;',
isConfirm: true,
onOk(){
}
});
//cofirm with title and Synchronous request
$vm.$alert(this.message, {
title: '提醒',
titleStyle: 'color:red;',
isConfirm: true,
isAsync: true,
onOk(success){
ajax({
//...ajax success call the parameter function
success();
})
}
});
```
##### TODO
* Custom button styles and content styles
## License
MIT