問題出在這裏 - 我調用一個函數,並且可以多次顯示一個對話框並等待用戶按下OK。之後 - 我想做別的事情。異步使用javascript承諾
我認爲解決方案需要使用Promise。但dialog.alert()調用的異步特性正在拋棄我。
function a()
{
if (condition_ok)
{
// there could be multiple dialogs
//
for (int i = 0; i < 2; ++i)
dialog.alert("press ok").then (()=> { console.log("done"); });
}
}
a();
// call b() after all the dialogs have been closed in a()
b();
'for(int i = 0;我<2; ++ i)'... int? –
應該是僞代碼......這是當你在同一時間使用多種語言時發生的情況。 – dashman