javascript - 未调用 Bootbox 回调函数
问题描述
我正在尝试在 Angular2 应用程序中使用 Bootbox。我有以下代码:
bootbox.confirm({
message: "Are you sure you want to complete this action?",
buttons: {
confirm: {label: 'Yes', className: 'btn-success'},
cancel: {label: 'No', className: 'btn-danger'}
},
callback: function (result: any) {
console.log('Response equals: ' + result);
}
});
确认框在调用时正确显示,当单击“是”或“否”按钮时,确认框会消失。但是,回调函数没有触发,因为我没有收到控制台消息。
这是我第一次尝试将 Bootbox 注入应用程序,所以我不确定为什么没有调用回调函数。
有任何想法吗?
解决方案
您是否尝试过使用功能(结果)删除':任何'。
bootbox.confirm({
message: "This is a confirm with custom button text and color! Do you like it?",
buttons: {
confirm: {
label: 'Yes',
className: 'btn-success'
},
cancel: {
label: 'No',
className: 'btn-danger'
}
},
callback: function (result) {
console.log('This was logged in the callback: ' + result);
}
});
http://bootboxjs.com/examples.html#bb-confirm-dialog。回调只接受一个参数,即结果。
推荐阅读
- flutter - 模仿 iOS 13 全屏对话框
- java - 使用 InputStream 下载大文件
- python-3.x - 如何合并具有相同长度的二维列表
- flutter - 在颤动中溢出 230 像素
- database - 如何在二级索引而不是主索引上执行 transaction.insert_or_update?
- python - 同一项目的内存分配
- java - How to get Integer#parseInt to return a value in case of overload
- flutter - 当图像 url 在颤动中失败时应用程序崩溃
- c - 为什么 execve 返回的结果与用户不同
- angular - 如何将数据传递给精确的兄弟组件?