Electron 如何以电子方式显示本机图像

Electron 如何以电子方式显示本机图像,electron,Electron,我有一个电子WebView。我想截图它的内容,并显示在我的应用程序的某个地方 我尝试过使用该方法,该方法返回一个 如何将该图像添加到DOM中并在我的应用程序上显示?我不知道如何转换它 为此,您可以使用@Mikaeru建议的示例 俘获 const wv=document.getElementById('视图') 常量b=document.getElementById('capture')) 常量i=document.getElementById('show') b、 addEventListe

我有一个电子
WebView
。我想截图它的内容,并显示在我的应用程序的某个地方

我尝试过使用该方法,该方法返回一个

如何将该图像添加到DOM中并在我的应用程序上显示?我不知道如何转换它

为此,您可以使用@Mikaeru建议的示例


俘获
const wv=document.getElementById('视图')
常量b=document.getElementById('capture'))
常量i=document.getElementById('show')
b、 addEventListener('单击',()=>{
wv.capturePage((img)=>{
i、 src=img.toDataURL()
})
})

到目前为止您做了什么?你能分享你的代码吗?使用这个方法可能是最好的选择。这就解释了其中的原因。
<html>
  <body>
    <webview id="view" src="https://www.github.com/" style="width:320px; height:240px">
    </webview>
    <button id="capture">Capture</button>
    <img id="show" src="" />
    <script>
      const wv = document.getElementById('view')
      const b = document.getElementById('capture')
      const i = document.getElementById('show')
      b.addEventListener('click', () => {
        wv.capturePage((img) => {
          i.src = img.toDataURL()
        })
      })
    </script>
  </body>
</html>