createPop.js 389 Bytes
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
import Vue from 'vue'
export default function create (comp, props) {
  const app = new Vue({
    render (h) {
      return h(comp, { props })
    }
  }).$mount()
  // app.$el为该虚拟DOM的真实DOM
  document.body.appendChild(app.$el)
  // 销毁
  const com = app.$children[0]
  com.remove = function () {
    document.body.removeChild(app.$el)
    app.$destroy()
  }
  return com
}