重写element-ui $message 解决消息多次弹出的问
作者:
小枫学幽默 | 来源:发表于
2020-06-24 16:43 被阅读0次/***重写element-ui $message 解决消息多次弹出的问题**/
import {
Message
} from "element-ui";
let messageInstance = null;
const overrideMessage = (options) => {
if(messageInstance) {
messageInstance.close();
}
messageInstance = Message(options);
};
["error","success","info","warning"].forEach(type => {
overrideMessage[type] = options => {
if (typeof options === "string") {
options = {
message: options
};
}
options.type = type;
return overrideMessage(options);
};
});
/***重写message**/
Vue.use(ElementUI, {
size: "small",
zIndex: 3000
});
Vue.prototype.$message = overrideMessage;
本文标题:重写element-ui $message 解决消息多次弹出的问
本文链接:https://www.haomeiwen.com/subject/kczrfktx.html
网友评论