How to preload multiple js in electron webview

2019-06-13 05:29发布

here is electron doc ex:

<webview src="https://www.github.com/" preload="./test.js"></webview>

how to preload multi js like:

<webview src="https://www.github.com/" preload="./test.js,./test2.js"></webview>

1条回答
姐就是有狂的资本
2楼-- · 2019-06-13 05:48

In electron > webview > preload doc say:

When the guest page doesn’t have node integration this script will still have access to all Node APIs, but global objects injected by Node will be deleted after this script has finished executing.

so I can use nodejs require in js, following is my code:

test.html

<webview id="wv" src="test-webview-preload-multi-js2.html" preload="app.js"></webview>

app.js

require("./app2.js")
require("./app3.js")
查看更多
登录 后发表回答