UNPKG

yyzone

Version:

yyzone vue components and utils

39 lines (35 loc) 874 B
import Vue from 'vue' import Modal from './modal.vue' Modal.newInstance = properties => { const _props = properties || {} const Instance = new Vue({ data: _props, render (h) { return h(Modal, { 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 modal = Instance.$children[0] return { component: modal, show () { modal.visible = true }, hide () { modal.visible = false modal.$parent.hide() } } } export default Modal