forked from Spikef/vmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.js
47 lines (41 loc) · 1.37 KB
/
install.js
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
import Prompt from './';
export default configs => {
configs.template += `<prompt v-ref:prompt></prompt>`;
configs.components.Prompt = Prompt;
return (Vue, vm) => {
var opts = {
title: '',
content: '',
value: '',
invalid: false,
message: '',
placeholder: '',
validator: null,
confirm: null,
cancel: null,
btn1: '取消',
btn2: '确定'
};
Vue.prototype.$Prompt = (title, confirm, cancel, options) => {
if (typeof title === 'string') {
options = options || {};
options.title = title;
} else if (typeof title === 'object') {
options = title;
}
if (typeof confirm === 'function') {
options = options || {};
options.confirm = confirm;
} else if (typeof confirm === 'object') {
options = Object.assign(options, confirm);
}
if (typeof cancel === 'function') {
options = options || {};
options.cancel = cancel;
} else if (typeof cancel === 'object') {
options = Object.assign(options, cancel);
}
vm.$refs.prompt._show(Object.assign({}, opts, options));
};
}
}