faker_666 2022-02-11 17:13 采纳率: 100%
浏览 41
已结题

前端消息提示两次后第一次提示关不掉

(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.

报错截图:

img

  • 写回答

2条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 系统已结题 3月18日
      • 已采纳回答 3月10日
      • 创建了问题 2月11日

      悬赏问题

      • ¥15 matlab画三维流场
      • ¥100 IIC通讯数据算法分析
      • ¥15 matlab 绘制涡流场
      • ¥15 依存句法分析如何与BERT模型及GCN相结合
      • ¥66 有偿收一个会Python 与unitysocket通信,会简单mediapipe手势识别的哥
      • ¥15 药店卖药设计使利润最大
      • ¥15 模拟银行实现VIP服务
      • ¥20 ECU在实车上can通讯失败或不稳定
      • ¥15 关于VB.net调用Excel如何打包的问题?
      • ¥15 VB6.0+WebBrowser如何实现网页内嵌图片按钮点击