Node.js 使用数组解构作为Inquirer多项选择题的值?
我左右为难,我的代码是:Node.js 使用数组解构作为Inquirer多项选择题的值?,node.js,command-line-interface,Node.js,Command Line Interface,我左右为难,我的代码是: inquirer.prompt([ { type: 'checkbox', name: 'Keywords', message: 'Please select the keywords you would like to use with a maximum of 5.', choices: [ NewDescriptionKeys[0], NewDescriptionKey
inquirer.prompt([
{
type: 'checkbox',
name: 'Keywords',
message: 'Please select the keywords you would like to use with a maximum of 5.',
choices: [
NewDescriptionKeys[0],
NewDescriptionKeys[1],
NewDescriptionKeys[2],
NewDescriptionKeys[3],
NewDescriptionKeys[4],
]
}
]).then(function (answers) {}//other non-related code is here
我的问题是,我有时会有5个以上的结果,需要显示所有结果,这样用户就可以选择他们想要使用的结果,然后取消选择他们不想要的结果。我已经尝试放置每个数组,直到我达到可能返回的最大值,但这只是将未定义的结果放在所有地方,有什么建议吗 为什么不这样做:
{
type: 'checkbox',
name: 'Keywords',
message: 'Please select the keywords you would like to use with a maximum of 5.',
choices: NewDescriptionKeys
}
简化为
{
type: 'checkbox',
name: 'Keywords',
message: 'Please select the keywords you would like to use with a maximum of 5.',
choices: NewDescriptionKeys
}
及
请使用空格键选择不输入(返回)
(按可选择、全部切换、反向选择)
如果在未选择的情况下按enter键(不按空格键),则它将提交未选择的结果,其中包含空数组
以提交方式输入工作不知道为什么我没有尝试,非常感谢。它工作得很好。
(Press <space> to select, <a> to toggle all, <i> to inverse selection)