createPop.js 737 Bytes
Newer Older
纪泽龙's avatar
纪泽龙 committed
1 2 3 4 5 6 7 8
/*
 * @Author: your name
 * @Date: 2021-07-17 16:35:29
 * @LastEditTime: 2022-01-17 10:32:50
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /gassafety-web/src/utils/createPop.js
 */
耿迪迪's avatar
耿迪迪 committed
9 10
import Vue from 'vue'
export default function create (comp, props) {
纪泽龙's avatar
纪泽龙 committed
11
  console.log("comp",comp)
耿迪迪's avatar
耿迪迪 committed
12 13 14 15 16 17 18 19 20
  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]
纪泽龙's avatar
纪泽龙 committed
21

耿迪迪's avatar
耿迪迪 committed
22 23 24 25 26 27 28
  com.remove = function () {
    document.body.removeChild(app.$el)
    app.$destroy()
  }
  return com
}