import ConfirmComponent from '@/components/Confirm'

let $vm

export default {
  install (Vue) {
    if (!$vm) {
      const Confirm = Vue.extend(ConfirmComponent) // 补齐方法

      $vm = new Confirm({
        el: document.createElement('div')
      })

      document.body.appendChild($vm.$el);
    }

    Vue.prototype.$confirmEx = (title, content, callback) => {
        $vm.title = title || '提示';
        $vm.content = content;
        $vm.visible = true;

        $vm.$on("confirm", callback);
    };
  }
}