在安装脚手架的时候,都会弹出一些命令来让我们选择,这其实是用了node的inquirer包,下面就来看下
let inquirer=require('inquirer');
let question=[
{type:'input',
name:'username',
message:'姓名',
default:''
},
{type:'confirm',
name:'isMan',
message:'man',
default:true
},
{type:'list',
name:'study',
message:'学历',
choices:['小学','初中','高中','大学','研究生']
},
{type:'checkbox',
name:'hobby',
message:'爱好',
choices:['篮球','足球','游泳']
}
]
inquirer.prompt(question).then(answer=>{console.log(answer)})