当这个问题被问到时,我试图从用户那里获得一个整数值:
let q4 = {
type: 'list',
name: 'manager',
message: 'Who do they report to?',
choices: ['Jen','Rachel','Tania']
};
let answerProcessing = (answer) => {
console.log(answer.manager)
}但我无法从文档中找出它,我也看不到任何与此类似的问题。也许这真的很明显,但我无法获得非字符串响应。
发布于 2020-12-23 05:01:21
弄清楚了:
console.log(q4.choices.indexOf(answer.role));这将给出索引值。因为我看不到其他类似的问题,所以把它留在了上面。
https://stackoverflow.com/questions/65415706
复制相似问题