core.js
954 Bytes
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
/**
* 插件
*/
import store from 'yoho-store';
import cookie from 'yoho-cookie';
import iView from 'iview';
import 'iview/dist/styles/iview.css';
import components from '../components';
import _ from 'lodash/core';
export default {
loadGlobalComponents(Vue) {
_.each(components, component => {
if (component.length) {
Vue.component(component[0], component[1]);
} else {
Vue.component(component.name, component);
}
});
},
defineVueProp(Vue) {
Vue.prop = (key, value) => {
Vue[`$${key}`] = Vue.prototype[`$${key}`] = value;
};
},
install(Vue) {
// 定义Vue全局属性
this.defineVueProp(Vue);
// 加载核心组件
this.loadGlobalComponents(Vue);
// 附加Vue原型属性
Vue.prop('store', store);
Vue.prop('cookie', cookie);
Vue.use(iView);
}
};