Files
lina/src/utils/Message.js

21 lines
558 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 重置message防止重复点击重复弹出message弹框
import { Message as elMessage } from 'element-ui'
let messageDom = null
const Message = (options) => {
// 判断弹窗是否已存在, 若存在则关闭
if (messageDom) messageDom.close()
messageDom = elMessage(options)
}
const typeArray = ['success', 'error', 'warning', 'info']
typeArray.forEach(type => {
Message[type] = options => {
if (typeof options === 'string') options = { message: options }
options.type = type
return Message(options)
}
})
export { Message }