我正在构建一个不能使用webview
的应用程序,因为它不能做我想做的所有事情,而使用mainWindow
则可以。
但是,我需要使用整个javascript文件,而不仅仅是文本。
示例:
const {app, BrowserWindow} = require('electron');
let mainWindow;
app.on('ready', function() {
mainWindow = new BrowserWindow({
width: 1024,
height: 1024
});
mainWindow.loadURL("https://www.google.com/");
mainWindow.webContents.executeJavaScript('alert("this is a test!");');
// I want to load an entire file for the .executeJavaScript()
// I have a file within the same directory called 'index.js'
// How would I implement this?
mainWindow.webContents.executeJavaScript('???');
});
https://stackoverflow.com/questions/52449969
复制相似问题