![](/img/trans.png)
[英]console.log() an object does not log the method added via prototype in node js console. Or how to print the prototypes also?
[英]How is it possible in Node js to display list of options via console log and ask user to input a option from the displayed list via console log
如何在 Node js 中通過控制台日志顯示選項列表並要求用戶通過控制台日志從顯示的列表中輸入一個選項
預期行為 user@desktop:~$ node test.js
- 選項1
- 選項 2
- 選項 3
Select 選項繼續:3 您已選擇選項 3
想出一個使用查詢器模塊的方法
const inquirer = require('inquirer');
function main() {
inquirer
.prompt([
{
type: 'list',
name: 'Options',
message: 'Select an Item from below list',
choices: ['alligator', 'crocodile', 'Exit'],
},
])
.then(answers => {
if (answers.Options == "Exit"){
process.exit()
} else {
console.info('Answer:', answers.Options);
}
});
}
if (require.main === module) {
main();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.