Bootbox 提示无法正常工作

Bootbox prompt not working as it should

当我使用 bootbox 提示符时,脚本不会暂停一段时间来接受用户的输入,就像 javascript 提示符一样有效,整个程序运行时无需用户输入。我不知道为什么?任何帮助都是可观的。

this.num = bootbox.prompt("Enter a number of nodes" , function(result)
        {
            if(result == null)
            {
                console.log("Cancelled");
            }else{

                return result;
            }
        });

        console.log(this.num); 

Bootbox 对话框不是阻塞事件,因此 一切 需要 仅在关闭对话框时才发生的事情需要在回调中功能。

已涵盖on the Bootbox site:

The only required argument for alert calls is message; callback is required for confirm and prompt calls in order to determine what the user's response was. Even when calling alert a callback is useful to determine when the user dismissed the dialog since our wrapper methods can't & don't block like their native counterparts; they are asynchronous rather than synchronous.

这将适用于 任何 非本地模态,而不仅仅是 Bootbox(以及底层 Bootstrap 模态)。