(function () {
window.Message = class Message {
constructor(type, message, timerout) {
this.dom = null;
this.type = type;
this.message = message;
this.timerout = timerout;
}
showMessage() {
let writediv = document.createElement("div");
writediv.setAttribute("class", "wr")
writediv.innerHTML = this.message;
this.dom = writediv;
switch (this.type) {
case "success":
writediv.setAttribute("class", "wr1");
break;
case "waring":
writediv.setAttribute("class", "wr2");
break;
case "error":
writediv.setAttribute("class", "wr3");
break;
}
document.body.append(writediv);
setTimeout(() => {
this.hiddenMessage();
}, this.timerout);
}
hiddenMessage() {
document.body.removeChild(this.dom);
}
}
})()
报错内容:Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
报错截图: