import Vue from 'vue';
export function create(Component, options) {
//把组件传进入
const Ctor = Vue.extend(Component);
//创建组件实例,挂载到dom
const Comp = new Ctor({
propsData: options
}).$mount();
//将组件实例添加到body上
document.body.appendChild(Comp.$el);
console.log(Comp)
Comp.remove = () => {
//删除dom
document.body.removeChild(Comp.$el);
//销毁组件
Comp.$destroy();
};
//返回Component组件实例
return Comp;
}
网友评论