首页 > 解决方案 > 永远不会调用 showMessageBox 承诺

问题描述

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

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

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

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

标签: javascriptelectron

解决方案


尝试:

 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);
  });

推荐阅读