1、尝试在远端网页直接require('electron')报以下错误
报该错误是因为当前窗口不能访问到node.js环境
Electron的一个主要特性就是能在渲染进程中运行Node.js,html或者vue项目不能直接require('electron')
想要壳与网页分离,并且达成交互,需要双向定义事件,而electron只需在壳中引用
2、创建浏览器窗口// main.jsmainWindow = new BrowserWindow({
width: 360,
height: 600,
x: 0,
y: 0,
autoHideMenuBar: true,
// icon:path.join(__dirname, 'favicon.ico'),
alwaysOnTop: true,
// closable: false,
// frame: false,
webPreferences: {
nodeIntegration: true,
webSecurity: false, //禁用同源策略
plugins: true, //是否支持插件
nativeWindowOpen: true, //是否使用原生的window.open()
webviewTag: true, //是否启用 tag标签
// preload: path.join(app.getAppPath(), './static/preload.js'),
sandbox: true, //沙盒选项,这个很