vue使用qrcodejs2在彈窗內生成二維碼報Cannot read property 'appendChild' of null"錯誤


解決方法:

先生成彈窗節點之后,在延遲執行生成二維碼的加載。

          _this.showErCodePopup = true;//生成彈窗
          setTimeout(() => {
            let shareUrl = `https://www.baidu.com/`;
            let qrcode = new QRCode("qrcode", {
              text: shareUrl,
              width: 120, //圖像寬度
              height: 120, //圖像高度
            });
            qrcode.clear(); //清除二維碼
            qrcode.makeCode(shareUrl); //生成另一個新的二維碼
          }, 500);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM