electron嵌入webview显示空白问题

1. 页面是这样子


<html>
  <body>
    <webview id="foo" src="https://www.baidu.com/" style="display:inline-block; width:640px; height:480px">webview>
  body>
html>

当这个webview启动的时候却是空白。

2.解决办法

webPreferences配置下webviewTag: true
如下:

const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      webviewTag: true,
      preload: path.join(__dirname, 'preload.js')
    }
  })```

你可能感兴趣的:(electron嵌入webview显示空白问题)