如何在电子webview中预加载多个js [英] How to preload multiple js in electron webview

查看:507
本文介绍了如何在电子webview中预加载多个js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是电子文档,例如:

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

如何像这样预加载多个js

how to preload multi js like:

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

推荐答案

在电子>网络视图>预加载文档中说:

In electron > webview > preload doc say:

当来宾页面没有节点集成时,该脚本仍将有权访问所有Node API,但是由Node注入的全局对象将在此脚本执行完毕后删除.

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.

所以我可以在js中使用nodejs require,下面是我的代码:

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

test.html

test.html

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

app.js

require("./app2.js")
require("./app3.js")

这篇关于如何在电子webview中预加载多个js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆