問題描述
如何替換電子中javascript prompt
的功能?
How to replace the function of javascript prompt
in electron?
誰能給我一個例子?
我嘗試使用函數prompt
,但報錯:
I tried to use the function prompt
, but got an error:
未捕獲的錯誤:prompt() 被支持并且將不被支持.
Uncaught Error: prompt() is and will not be supported.
推薦答案
prompt
, confirm
和 alert
是阻塞執行線程的函數腳本直到用戶輸入,這就是電子團隊不支持它的原因.相反,您可以出于同樣的原因使用一些第三方軟件包.
prompt
, confirm
and alert
are functions which blocks the execution thread of the script until a user input and that's the reason electron team didn't supported it. Instead you can use some third party package for the same reason.
這里有一些以異步方式提供此功能的包
Here are some packages which provides this functionality in async way
https://www.npmjs.com/package/smalltalk
https://www.npmjs.com/package/vex-js
https://www.npmjs.com/package/dialogs
這篇關于在 Electron 中替換“提示"的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!