core.js
665 Bytes
/**
* 插件
*/
import store from 'yoho-store';
import cookie from 'yoho-cookie';
import components from '../components';
import {each} from 'lodash';
export default {
loadGlobalComponents(Vue) {
each(components, component => {
Vue.component(component.name, component);
});
},
defineVueProp(Vue) {
Vue.prop = (key, value) => {
Vue[`$${key}`] = Vue.prototype[`$${key}`] = value;
};
},
install(Vue) {
// 定义Vue全局属性
this.defineVueProp(Vue);
// 注册全局components
this.loadGlobalComponents(Vue);
// 附加Vue原型属性
Vue.prop('store', store);
Vue.prop('cookie', cookie);
}
};