UNPKG

@58fe/p5

Version:

pc端vue组件

51 lines (45 loc) 842 B
import Vue from 'vue'; import Loading from './../../components/loading'; const plugin = { install(vue, props = {}) { const LoadingPlugin = Vue.extend(Loading); let $vm = new LoadingPlugin({ el: document.createElement('div') }); document.body.appendChild($vm.$el); /* const loading = { show() { if ($vm.show) return; $vm.value = true; }, hide() { $vm.value = false; } }; */ function loading(options = {}) { $vm = Object.assign($vm, props, options); return { show: () => { if ($vm.show) return; $vm.value = true; }, hide: () => { $vm.value = false; } }; } if (!vue.$p5) { vue.$p5 = { loading }; } else { vue.$p5.loading = loading; } vue.mixin({ created: function() { this.$p5 = vue.$p5; } }); } }; export default plugin;