Skip to content

Commit 3975e6a

Browse files
committed
have a base idea
1 parent 7d719f7 commit 3975e6a

File tree

1 file changed

+58
-4
lines changed

1 file changed

+58
-4
lines changed

index.js

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,66 @@
1+
import confirm from '../../components/modals/confirm.vue';
2+
13
var modal = {
24
install: function (Vue, options) {
35

4-
var defaultOptions = Object.assgin({
5-
name: '$modal'
6-
},options)
7-
Vue.prototype[defaultOptions.name] = function () {
6+
var defaultOptions = Object.assign({
7+
name: '$modal',
8+
id: 'modal'
9+
}, options)
10+
11+
this.init(defaultOptions.id);
12+
13+
console.log('defaultOptions', defaultOptions, Vue.prototype);
814

15+
var modals = Vue.prototype[defaultOptions.name] = {};
16+
17+
console.log('confirm', confirm)
18+
confirm.methods.$ok = function () {
19+
console.log('osdjcopsjpojcpoj')
920
}
21+
modals.confirm = options => {
22+
return new Promise((res, rej) => {
23+
console.log('options', options)
24+
new Vue({
25+
render: h => h(confirm, {
26+
props: options,
27+
on: {
28+
abc: function (v) {
29+
console.log('abc')
30+
res(v)
31+
}
32+
}
33+
})
34+
}).$mount('#' + defaultOptions.id)
35+
36+
this.init(defaultOptions.id)
37+
})
38+
39+
40+
}
41+
42+
43+
44+
45+
46+
47+
48+
49+
// Object.keys(defaultOptions.modals).forEach(function (v) {
50+
// modals[v] = function (box) {
51+
// Vue.component(v, defaultOptions.modals[v])
52+
// console.log('box', box.content)
53+
// console.log(v, defaultOptions.modals[v])
54+
55+
// // document.getElementsByTagName('body')[0].appendChild('<confirm></confirm>')
56+
// }
57+
58+
// })
59+
},
60+
init: name => {
61+
const div = document.createElement('div');
62+
div.setAttribute('id', name || 'modal');
63+
document.getElementsByTagName('body')[0].appendChild(div)
1064
}
1165
}
1266

0 commit comments

Comments
 (0)