问题描述
我正在尝试使用 MysqL 中的一列值作为查询器提示中的列表选项。但是,当应该正确定义 sql 表中的值时,列表项会为每个列表值返回“未定义”。当我之前在代码中使用相同的结构时,我无法弄清楚为什么查询器将列表值返回为“未定义”。
const addEmployee = () => {
connection.query('SELECT id,title FROM roles',(err,resRole) => {
inquirer.prompt([
{
name: 'firstName',type: 'input',message: 'Enter the employee\'s first name:',},{
name: 'lastName',message: 'Enter the employee\'s last name:',{
name: 'roleId',type: 'list',message: 'Select the employee\'s role:',choices: resRole
},{
name: 'manager',message: 'Does this employee report to anyone?',choices: ['Yes','No']
}
])
这是我在终端中得到的结果:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)