vue中使用element自定義彈出框

1. 在main.js中全局註冊定義


import { Message,MessageBox } from 'element-ui';

Vue.Message = new DonMessage()
//自定義提示語彈窗
window.$dcMsg = (txt='這是提示語句',timer='2000') => {
  MessageBox.alert(txt, '', {
    dangerouslyUseHTMLString: true,
    customClass: 'dc-message-popou',
    lockScroll: true,
    showConfirmButton:false,
    showClose:false,
    center: true,
    callback: action => {
    }
  });
  return new Promise((resolve,reject) => {
    setTimeout(() => {
      $('.dc-message-popou').find('.el-button').trigger('click');
      resolve();
    },timer)

  })
}

2.在項目中使用

window.$dcMsg("請檢查網絡")

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章