html - Webview在electronic js中返回空白白页

标签 html electron

我正在使用样板 Electron js快速入门,并尝试从其API文档渲染Webview。这是我的index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Hello World!</title>
  </head>
  <body>
    <webview id="foo" src="https://www.github.com/" style="display:inline-flex; width:640px; height:480px"></webview></webview>
  </body>
</html>

它只是呈现一个空白屏幕。我在Ubuntu和OSX上尝试过。控制台中没有错误。我什至不知道从哪里开始调试。

最佳答案

 mainWindow = new BrowserWindow({
    width: 1280,
    height: 1080,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      webviewTag: true
    },
  })

创建浏览器窗口时,必须在webPreferences内启用webviewTag。

关于html - Webview在electronic js中返回空白白页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58210650/

相关文章:

node.js - 当我使用 npm-run-all 时,如何使用 VSCode 启用 Electron Main 和 Renderer 的调试?

node.js - 首次加载时在Electron中启动VLC

php - 将 for 循环的值放入数组中

javascript - 展开/折叠跨度?

html - 为什么我的 ul CSS 在 IE 中工作但在 Chrome 中不工作?

node.js - 模块构建失败(来自 ./node_modules/html-loader/dist/cjs.js):

electron - Electron 'download-progress'没什么

html - wordpress 中的简单站点页脚

javascript - Android Webview 不加载 javascript 注入(inject)的图像

ios - 如何在Mac上的iPhone Simulator上运行ElectronJS应用程序?