How to preload multiple js in electron webview

谁都会走 提交于 2019-12-08 11:35:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!