作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面的代码只是使用 Electron Node 模块显示对话框。
app.js
const { dialog } = require('electron')
const response = dialog.showMessageBox(null);
console.log(response);
const response = dialog.showMessageBox(null);
^
TypeError: Cannot read property 'showMessageBox' of undefined
at Object.<anonymous> (C:\Users\1217688\Desktop\WebApp\node-elect-test\app.js:2:25)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Function.Module.runMain (module.js:701:10)
at startup (bootstrap_node.js:190:16)
at bootstrap_node.js:662:3
最佳答案
在渲染器进程中,添加 .remote
const { dialog } = require('electron').remote
关于node.js - 类型错误 : Cannot read property 'showMessageBox' of undefined electron in node js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55761223/
我是一名优秀的程序员,十分优秀!