ConfirmPlugin.js 520 B

12345678910111213141516171819202122232425
  1. import ConfirmComponent from '@/components/Confirm'
  2. let $vm
  3. export default {
  4. install (Vue) {
  5. if (!$vm) {
  6. const Confirm = Vue.extend(ConfirmComponent) // 补齐方法
  7. $vm = new Confirm({
  8. el: document.createElement('div')
  9. })
  10. document.body.appendChild($vm.$el);
  11. }
  12. Vue.prototype.$confirmEx = (title, content, callback) => {
  13. $vm.title = title || '提示';
  14. $vm.content = content;
  15. $vm.visible = true;
  16. $vm.$on("confirm", callback);
  17. };
  18. }
  19. }