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("请检查网络")