小编bea*_*ang的帖子

在渲染过程中没有定义electron.remote

我试图在用户单击按钮时使用对话框,错误出现错误Uncaught TypeError: Cannot read property 'dialog' of undefined。控制台日志的结果是undefined

main.js 文件

const { app, BrowserWindow } = require('electron');
const path = require('path');

if (require('electron-squirrel-startup')) {
  app.quit();
}

const createWindow = () => {
  const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true
    }
  });
  mainWindow.loadFile(path.join(__dirname, './src/index.html'));

  mainWindow.webContents.openDevTools();
};

app.on('ready', createWindow);

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  if (BrowserWindow.getAllWindows().length === 0) {
    createWindow();
  }
}); …
Run Code Online (Sandbox Code Playgroud)

javascript electron

1
推荐指数
1
解决办法
992
查看次数

标签 统计

electron ×1

javascript ×1