const employeeQuestion = [
{
type: "list",
name: "employeeTitle",
message: "What's the employee's title",
choices: ["Engineer", "Intern"]
},
//when role is engineer is true, ask this question
{
when: input => {
return input.role == "Engineer"
},
type: "input",
name: "github",
message: "Enter your github username:",
},
//when role is intern is true, ask this question
{
when: input => {
return input.role == "Intern"
},
type: "input",
name: "school",
message: "What's the school you enrolled in ?",
},
]
我的想法是我想利用查询者的when方法,所以是否询问用户的 github 或学校的问题取决于员工标题的答案。但是当我在命令行上运行 node 时,从未出现过询问 github / school 的问题。我想知道我是否使用了错误的方法或是否有其他选择。