gpt4 book ai didi

javascript - 有没有办法在出现提示时使用查询器中以前的答案(查询器 v6)?

转载 作者:搜寻专家 更新时间:2023-11-01 04:22:08 28 4
gpt4 key购买 nike

所以我想做的是在进一步提问时使用以前的答案。基本上这样我就可以显示将要创建的内容的摘要并要求进行验证。

this.prompt([   
{
type: 'input',
name: 'name',
message: 'What is your name?'
default: 'Jake'
},
{
type: 'confirm',
name: 'summary',
message: 'Is this information correct? Your name is:' + answers.name',
}

有没有简单的方法可以做到这一点?或者另一种方法来实现列出所有以前答案的摘要类型的东西?

最佳答案

任一嵌套查询器调用:

inquirer
.prompt({
type: 'list',
name: 'chocolate',
message: "What's your favorite chocolate?",
choices: ['Mars', 'Oh Henry', 'Hershey']
})
.then(() => {
inquirer.prompt({
type: 'list',
name: 'beverage',
message: 'And your favorite beverage?',
choices: ['Pepsi', 'Coke', '7up', 'Mountain Dew', 'Red Bull']
});
});

或者使用when函数。

{
type: 'confirm',
name: 'summary',
message: 'Is this information correct? Your name is:' + answers.name,
when: function( answers ) {
// Only run if user set a name
return !!answers.name;
},
}

关于javascript - 有没有办法在出现提示时使用查询器中以前的答案(查询器 v6)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49520423/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com