-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (51 loc) · 1.25 KB
/
index.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
48
49
50
51
52
53
import wpicker from './components/index.vue'
import dpicker from './components/DatePicker.vue'
const pickerObj = {
__installed: false,
__Vue: null,
vm: null,
__config: null,
install (Vue) {
if (this.__installed) return
this.__installed = true
this.__Vue = Vue
Vue.prototype.$wheelPicker = pickerObj
Vue.component('wheel-picker', wpicker)
Vue.component('wheel-datepicker', dpicker)
},
show (config) {
if (this.vm) {
this.vm.$el.remove()
this.vm = null
}
pickerObj.__config = config || {}
let propBody = {}
const type = pickerObj.__config.mode || 'picker'
const compt = type === 'picker' ? wpicker : dpicker
Object.keys(pickerObj.__config).map(itm => {
propBody[itm] = pickerObj.__config[itm]
})
propBody.value = true
const node = document.createElement('div')
document.body.appendChild(node)
this.vm = new this.__Vue({
name: 'wheel-picker',
el: node,
components: {
'picker': compt
},
render (h) {
return h('picker', {
props: propBody,
on: {
change: config.cb || pickerObj.cb
}
})
}
})
},
cb (type) {
console.log('cb type:>>' + type)
}
}
export default pickerObj