main.js中添加webview配置信息
const mainWindow = new BrowserWindow({ width: 800, height: 600, webPreferences: { preload: path.join(__dirname, 'preload.js'), webviewTag: true, // 开启webview } })
index.html
<style> body{ margin: 0; padding: 0; width: 100vw; height: 100vh; } .webview{ width: 100%; height: 100%; } </style> <body> <webview class="webview" src="http://***.com" preload="./render.js"></webview> <!-- You can also require other files to run in this process --> <script src="./renderer.js"></script> </body>
标签:preload,开启,height,width,electron,webview,js From: https://www.cnblogs.com/jqynr/p/17503142.html