UNPKG

yyzone

Version:

yyzone vue components and utils

40 lines (36 loc) 972 B
import Vue from 'vue' import Loading from './loading.vue' Loading.newInstance = properties => { const _props = properties || {} const Instance = new Vue({ data: _props, render (h) { return h(Loading, { props: _props }) }, methods: { hide () { setTimeout(() => { this.onRemove() this.$el && document.body.removeChild(this.$el) }, 300) } } }) const component = Instance.$mount() document.body.appendChild(component.$el) const loading = Instance.$children[0] return { component: loading, show (options) { loading.visible = true loading.instanceTheme = options && options.theme || 'dark' }, hide () { loading.visible = false loading.$parent.hide() } } } export default Loading