1.终端和node.js的io交互
var readline = require('readline');
var rl = readline.createInterface(process.stdin,process.studout);
rl.setPrompt('请选择');
rl.prompt();
rl.on('line',(line) => {
var str = line.trim();
console.log('你输入的是:' + line.trim());
}
rl.prompt();
}).on('close',() => {
console.log('bye');
process.exit(0);
});
2.浏览器和node.js的终端交互
1.获取前端页面 调用querystring方法窃听addListener参数data
请求req.addListener('data',(postdata) => {
str = str = postdata;
console.log(qs.parse(str)); //qs是调用querystring方法
});