DOMException:无法在“ ShadowRoot”上设置“ adoptedStyleSheets”属性:不允许在多个文档中共享构造的样式表

hud*_*xin 5 html2canvas

使用html2canvas时遇到?DOMException:无法在“ ShadowRoot”上设置“ adoptedStyleSheets”属性:不允许在多个文档中共享构造的样式表

 html2canvas(document.getElementById('qr-code-content'), {useCORS: true}).then(canvas => {
        document.getElementById('qr-code-content').append(canvas);
        this.base64ImgData = canvas.toDataURL();
        this.sharing = true;
      });
Run Code Online (Sandbox Code Playgroud)

Zah*_*ema 2

此 PR 解决了这个问题。https://github.com/niklasvh/html2canvas/pull/2020

如果您需要快速解决方案,您可以使用分叉,或者等到它合并并从主存储库获取它。