【问题标题】:showMessageBox promise is never called永远不会调用 showMessageBox 承诺
【发布时间】:2020-07-14 16:00:02
【问题描述】:

消息框正确显示,但是当我选择其中一个按钮时,不会触发关闭。这是我的代码:

dialog.showMessageBox(options, (response, checkboxChecked) => {
/* More code like log statements, opening error boxes, etc*/
}

选项定义为choices = ["Yes", "No"], message = "Confirm"

大括号内的代码永远不会运行。

【问题讨论】:

标签: javascript electron


【解决方案1】:

试试:

 const options = {
    type: 'question',
    buttons: ['Cancel', 'Yes, please', 'No, thanks'],
    defaultId: 2,
    title: 'Question',
    message: 'Do you want to do this?',
    detail: 'It does not really matter',
    checkboxLabel: 'Remember my answer',
    checkboxChecked: true,
  };

  dialog.showMessageBox(null, options, (response, checkboxChecked) => {
    console.log(response);
    console.log(checkboxChecked);
  });

【讨论】:

  • 添加 null 并不能解决问题
  • 不知道远程是什么意思,你可以试试dialog.showMessageBox
  • 这与我的项目导入 Electron 的方式有关,没有远程消息框根本不显示
  • 知道了,只是依赖项目然后进行导入。
  • 如果你把console.log(checkboxChecked);放在括号里,你就看不到它了吗?
猜你喜欢
  • 2016-05-06
  • 2019-11-29
  • 2021-11-04
  • 1970-01-01
  • 2021-03-04
  • 1970-01-01
  • 1970-01-01
  • 2016-06-13
  • 2017-05-31
相关资源
最近更新 更多