el-message
import { Message } from 'element-ui'
const showMessage = function (options) {
let obj={}
const messageDom = document.getElementsByClassName('el-message')[0]
if(typeof options!='object'){
obj.message=options
}
if (messageDom === undefined) {
obj.type=obj.type?obj.type:'warning'
Message(obj)
}
}
const arr = ['success', 'warning', 'info', 'error']
arr.forEach(type => {
showMessage[type] = options => {
let obj={}
if(typeof options!='object'){
obj.message=options
}
const messageDom = document.getElementsByClassName('el-message')[0]
if (messageDom === undefined) {
obj.type=obj.type?obj.type:'warning'
Message[type](obj)
}
};
});
export default showMessage;
import ShowMessage from '@/utils/index';
Vue.prototype.$message = ShowMessage;
this.$message.error('操作成功');