cmd: node app.js hello
app.js
var args = process.argv;
console.log(args);//[ ‘C:\\Program Files\\nodejs\\node.exe‘,‘E:\\jenkins\\workspace\\app.js‘,‘hello‘ ]
获取我们需要的参数:
var arg = process.argv.splice(2);
console.log(arg);// hello
时间: 2024-10-10 00:17:24