解决多次生成二维码的问题

467 阅读1分钟

image.png 每次点击都会添加img标签

image.png

解决如下:

image.png

 handleExtendDialog(row) {
     
      // this.qrcode();
      // 必须这样调用  否则会出现  appendChild  null  就是id为qrcode的dom获取不到 返回结果为null
      this.$nextTick(function() {
        let dom = document.getElementById("qrcode");
        // firstChild 属性返回被选节点的第一个子节点。
        while (dom.firstChild) {
          dom.removeChild(dom.firstChild);
        }
        //这里调用创建二维码
        this.qrcode();
      });
    },