We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
开始通过npm init 创建package.json的时候就有⼤量与⽤户的交互(当然也可以通过参数来忽略输⼊);⽽现在⼤多数⼯程都是通过脚⼿架 来创建的,使⽤脚⼿架的时候最明显的就是与命令⾏的交互,如果想⾃⼰做⼀个脚⼿架或者在某些时候要与⽤户进⾏交互,这个时候就不得 不提到inquirer.js了。 介绍 由于交互的问题种类不同,inquirer为每个问题提供很多参数: type:表⽰提问的类型,包括:input, confirm, list, rawlist, expand, checkbox, password, editor; name: 存储当前问题回答的变量; message:问题的描述; default:默认值; choices:列表选项,在某些type下可⽤,并且包含⼀个分隔符(separator); validate:对⽤户的回答进⾏校验; filter:对⽤户的回答进⾏过滤处理,返回处理后的值; transformer:对⽤户回答的显⽰效果进⾏处理(如:修改回答的字体或背景颜⾊),但不会影响最终的答案的内容; when:根据前⾯问题的回答,判断当前问题是否需要被回答; pageSize:修改某些type类型下的渲染⾏数; prefix:修改message默认前缀; suffix:修改message默认后缀。
语法结构
const inquirer = require('inquirer'); const promptList = [ // 具体交互内容 ]; inquirer.prompt(promptList).then(answers => { console.log(answers); // 返回的结果 })
The text was updated successfully, but these errors were encountered:
No branches or pull requests
开始通过npm init 创建package.json的时候就有⼤量与⽤户的交互(当然也可以通过参数来忽略输⼊);⽽现在⼤多数⼯程都是通过脚⼿架
来创建的,使⽤脚⼿架的时候最明显的就是与命令⾏的交互,如果想⾃⼰做⼀个脚⼿架或者在某些时候要与⽤户进⾏交互,这个时候就不得
不提到inquirer.js了。
介绍
由于交互的问题种类不同,inquirer为每个问题提供很多参数:
type:表⽰提问的类型,包括:input, confirm, list, rawlist, expand, checkbox, password, editor;
name: 存储当前问题回答的变量;
message:问题的描述;
default:默认值;
choices:列表选项,在某些type下可⽤,并且包含⼀个分隔符(separator);
validate:对⽤户的回答进⾏校验;
filter:对⽤户的回答进⾏过滤处理,返回处理后的值;
transformer:对⽤户回答的显⽰效果进⾏处理(如:修改回答的字体或背景颜⾊),但不会影响最终的答案的内容;
when:根据前⾯问题的回答,判断当前问题是否需要被回答;
pageSize:修改某些type类型下的渲染⾏数;
prefix:修改message默认前缀;
suffix:修改message默认后缀。
语法结构
The text was updated successfully, but these errors were encountered: