我使用的是VS代码1.15.1和Node.js版本6.11.4。
安装了‘cli-接口’之后,我想使用getChar()函数来询问用户输入的问题。我面临的问题是,在我输入一个字符(我确实按ENTER)后,没有任何东西被注册,提示后的代码永远不会被击中。下面是代码的外观。
var query = require('cli-interface');
let input;
while(input != 'q')
{
input = query.getChar('Choose an option','abcdeq');
switch(input){
...
}
}调试器控制台中显示的输出:
Please select an option
Choose one of (a/b/c/d/q)?
a
timeout after 10000 ms
c
timeout after 10000 ms
q
not available
b
cancelled because Node.js is unresponsive发布于 2018-03-20 20:08:54
VS代码目前不支持CLI-接口调试,因此使用Node.js命令行将使其工作。只需使用Node程序运行js文件,如下所示:
node <file_name>.jshttps://stackoverflow.com/questions/49376101
复制相似问题