-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
67 lines (63 loc) · 1.39 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import Chart from './components/s-chart/'
import Bar from './components/visuals/s-bar/'
import Pie from './components/visuals/s-pie/'
import Line from './components/visuals/s-line/'
import Radar from './components/visuals/s-radar/'
import Funnel from './components/visuals/s-funnel/'
import Scatter from './components/visuals/s-scatter/'
import Gauge from './components/visuals/s-gauge/'
import Axis from './components/plugins/s-axis/'
import Tooltip from './components/plugins/s-Tooltip/'
import Legend from './components/plugins/s-Legend/'
import { bus } from './utils'
const components = [
Chart,
Bar,
Pie,
Radar,
Line,
Funnel,
Gauge,
Scatter,
Axis,
Tooltip,
Legend
]
components.map(component => {
// 按需加载组件
component.install = Vue => Vue.component(component.name, component)
})
// 整体插件机制
const install = Vue => {
components.map(component => Vue.component(component.name, component))
const Bus = new Vue({
methods: {
emit(event, ...args) {
this.$emit(event, ...args)
},
on(event, callback) {
this.$on(event, callback)
},
off(event, callback) {
this.$off(event, callback)
}
}
})
Vue.prototype[bus] = Bus //事件总线放在原型上
}
const version = '0.2.5'
export {
Chart,
Bar,
Line,
Radar,
Pie,
Funnel,
Scatter,
Gauge,
Axis,
Tooltip,
Legend,
install,
version
}