问题
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:
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")
来源:https://stackoverflow.com/questions/41626780/how-to-preload-multiple-js-in-electron-webview