import Confirm from './rendering/components/confirm' // Confirm 组件
Vue.prototype.$Confirm= ((obj)=>{//挂载在原型上
return create(Confirm,obj).show(); //返回组件实例
})
let create = function (Component, props) {
//方式一:使用Vue.extend创建
const vm = new Vue({
render(h) {
return h(Component, {props})
}
}).$mount() // $mount()本质上将vdom=》dom
// // 通过vm.$el获取生成的dom
document.body.appendChild(vm.$el)
// // 删除函数
// // 获取组件实例
const comp = vm.$children[0]
comp.remove = () => {
document.body.removeChild(vm.$el)
vm.$destroy()
}
return comp
};