重写message,下一个弹框显示时关闭上一个弹框
/**重置message,防止重复点击重复弹出message弹框 */
import {
Message
} from 'element-ui';`在这里插入代码片`
let messageInstance = null;
const rewriteMessage = (options) => {
if (messageInstance) {
messageInstance.close()
}
messageInstance = Message(options)
}
['error', 'success', 'info', 'warning'].forEach(type => {
rewriteMessage[type] = options => {
if (typeof options === 'string') {
options = {
message: options
}
}
options.type = type
options.duration = 5000
return rewriteMessage(options)
}
})
image.png
在文件开头写好该文件的功能及开发者备注
image.png
image.png
image.png
网友评论