[英]How do I pass command line arguments to a Node.js program?
我有一个用 Node.js 编写的web服务器,我想用一个特定的文件夹启动。 我不确定如何访问 JavaScript 中的 arguments。我正在这样运行节点:
$ node server.js folder
这里server.js
是我的服务器代码。 Node.js 帮助说这是可能的:
$ node -h
Usage: node [options] script.js [arguments]
我将如何访问 JavaScript 中的那些 arguments? 不知何故,我无法在 web 上找到此信息。
参数存储在process.argv
process.argv
是一个包含命令行参数的数组。 第一个元素将是“节点”,第二个元素将是 JavaScript 文件的名称。 下一个元素将是任何其他命令行参数。
// print process.argv
process.argv.forEach(function (val, index, array) {
console.log(index + ': ' + val);
});
这将生成:
$ node process-2.js one two=three four
0: node
1: /Users/mjr/work/node/process-2.js
2: one
3: two=three
4: four
为了像常规 javascript 函数一样规范化参数,我在我的 node.js shell 脚本中执行此操作:
var args = process.argv.slice(2);
请注意,第一个 arg 通常是 nodejs 的路径,第二个 arg 是您正在执行的脚本的位置。
最新的正确答案是使用minimist库。 我们曾经使用node-optimist,但它已被弃用。
以下是直接从 minimist 文档中获取的如何使用它的示例:
var argv = require('minimist')(process.argv.slice(2));
console.dir(argv);
——
$ node example/parse.js -a beep -b boop
{ _: [], a: 'beep', b: 'boop' }
——
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
{ _: [ 'foo', 'bar', 'baz' ],
x: 3,
y: 4,
n: 5,
a: true,
b: true,
c: true,
beep: 'boop' }
const args = process.argv;
console.log(args);
这将返回:
$ node server.js one two=three four
['node', '/home/server.js', 'one', 'two=three', 'four']
Minimist :用于最小参数解析。
Commander.js :最常用于参数解析的模块。
Meow :Commander.js 的轻量级替代品
Yargs :更复杂的参数解析(重)。
Vorpal.js :具有参数解析的成熟/交互式命令行应用程序。
这里有几个很好的答案,但这一切似乎都很复杂。 这与 bash 脚本访问参数值的方式非常相似,并且正如 MooGoo 指出的那样,它已经为 node.js 提供了标准。 (只是为了让 node.js 的新手可以理解)
例子:
$ node yourscript.js banana monkey
var program_name = process.argv[0]; //value will be "node"
var script_path = process.argv[1]; //value will be "yourscript.js"
var first_value = process.argv[2]; //value will be "banana"
var second_value = process.argv[3]; //value will be "monkey"
function getArgs () {
const args = {};
process.argv
.slice(2, process.argv.length)
.forEach( arg => {
// long arg
if (arg.slice(0,2) === '--') {
const longArg = arg.split('=');
const longArgFlag = longArg[0].slice(2,longArg[0].length);
const longArgValue = longArg.length > 1 ? longArg[1] : true;
args[longArgFlag] = longArgValue;
}
// flags
else if (arg[0] === '-') {
const flags = arg.slice(1,arg.length).split('');
flags.forEach(flag => {
args[flag] = true;
});
}
});
return args;
}
const args = getArgs();
console.log(args);
输入
node test.js -D --name=Hello
输出
{ D: true, name: 'Hello' }
输入
node config/build.js -lHRs --ip=$HOST --port=$PORT --env=dev
输出
{
l: true,
H: true,
R: true,
s: true,
ip: '127.0.0.1',
port: '8080',
env: 'dev'
}
在 NodeJS 中解析命令行参数的最简单方法是使用stdio模块。 受 UNIX getopt
实用程序的启发,它很简单,如下所示:
var stdio = require('stdio');
var ops = stdio.getopt({
'check': {key: 'c', args: 2, description: 'What this option means'},
'map': {key: 'm', description: 'Another description'},
'kaka': {args: 1, required: true},
'ooo': {key: 'o'}
});
如果您使用此命令运行前面的代码:
node <your_script.js> -c 23 45 --map -k 23 file1 file2
然后ops
对象将如下所示:
{ check: [ '23', '45' ],
args: [ 'file1', 'file2' ],
map: true,
kaka: '23' }
所以你可以随意使用它。 例如:
if (ops.kaka && ops.check) {
console.log(ops.kaka + ops.check[0]);
}
还支持分组选项,因此您可以编写-om
而不是-o -m
。
此外, stdio
可以自动生成帮助/使用输出。 如果你调用ops.printHelp()
你会得到以下信息:
USAGE: node something.js [--check <ARG1> <ARG2>] [--kaka] [--ooo] [--map]
-c, --check <ARG1> <ARG2> What this option means (mandatory)
-k, --kaka (mandatory)
--map Another description
-o, --ooo
如果未给出强制选项(在错误消息之前)或错误指定(例如,如果您为选项指定单个 arg 而它需要 2),也会显示上一条消息。
npm install stdio
如果您的脚本名为 myScript.js 并且您希望将名字和姓氏“Sean Worthington”作为参数传递,如下所示:
node myScript.js Sean Worthington
然后在你的脚本中你写:
var firstName = process.argv[2]; // Will be set to 'Sean'
var lastName = process.argv[3]; // Will be set to 'Worthington'
命令行参数值得一看!
您可以使用主要符号标准设置选项( 了解更多)。 这些命令都是等效的,设置相同的值:
$ example --verbose --timeout=1000 --src one.js --src two.js
$ example --verbose --timeout 1000 --src one.js two.js
$ example -vt 1000 --src one.js two.js
$ example -vt 1000 one.js two.js
要访问这些值,首先创建一个选项定义列表,描述您的应用程序接受的选项。 type
属性是一个 setter 函数(提供的值通过 this 传递),使您可以完全控制接收到的值。
const optionDefinitions = [
{ name: 'verbose', alias: 'v', type: Boolean },
{ name: 'src', type: String, multiple: true, defaultOption: true },
{ name: 'timeout', alias: 't', type: Number }
]
接下来,使用commandLineArgs()解析选项:
const commandLineArgs = require('command-line-args')
const options = commandLineArgs(optionDefinitions)
options
现在看起来像这样:
{
src: [
'one.js',
'two.js'
],
verbose: true,
timeout: 1000
}
除了上述典型用法,您还可以配置 command-line-args 以接受更高级的语法形式。
形式为基于命令的语法(git 风格):
$ executable <command> [options]
例如。
$ git commit --squash -m "This is my commit message"
形式的命令和子命令语法(docker 风格):
$ executable <command> [options] <sub-command> [options]
例如。
$ docker run --detached --image centos bash -c yum install -y httpd
可以使用command-line-usage生成使用指南(通常在设置--help
时打印)。 请参阅下面的示例并阅读文档以了解如何创建它们。
一个典型的使用指南示例。
聚合物 cli使用指南是一个很好的现实例子。
还有很多东西要学习,请参阅wiki以获取示例和文档。
这是我的命名参数的 0-dep 解决方案:
const args = process.argv
.slice(2)
.map(arg => arg.split('='))
.reduce((args, [value, key]) => {
args[value] = key;
return args;
}, {});
console.log(args.foo)
console.log(args.fizz)
例子:
$ node test.js foo=bar fizz=buzz
bar
buzz
注意:当参数包含=
时,这自然会失败。 这仅用于非常简单的用法。
有一个应用程序。 嗯,模块。 嗯,不止一个,可能是数百个。
Yargs是其中之一,它的文档读起来很酷。
这是来自 github/npm 页面的示例:
#!/usr/bin/env node
var argv = require('yargs').argv;
console.log('(%d,%d)', argv.x, argv.y);
console.log(argv._);
输出在这里(它读取带有破折号等,短和长,数字等的选项)。
$ ./nonopt.js -x 6.82 -y 3.35 rum
(6.82,3.35)
[ 'rum' ]
$ ./nonopt.js "me hearties" -x 0.54 yo -y 1.12 ho
(0.54,1.12)
[ 'me hearties', 'yo', 'ho' ]
基于标准输入解析参数( --key=value
)
const argv = (() => {
const arguments = {};
process.argv.slice(2).map( (element) => {
const matches = element.match( '--([a-zA-Z0-9]+)=(.*)');
if ( matches ){
arguments[matches[1]] = matches[2]
.replace(/^['"]/, '').replace(/['"]$/, '');
}
});
return arguments;
})();
命令示例
node app.js --name=stackoverflow --id=10 another-argument --text="Hello World"
argv 的结果: console.log(argv)
{
name: "stackoverflow",
id: "10",
text: "Hello World"
}
项目.js
for(var i=0;i<process.argv.length;i++){
console.log(process.argv[i]);
}
终端:
nodemon app.js "arg1" "arg2" "arg3"
结果:
0 'C:\\Program Files\\nodejs\\node.exe'
1 'C:\\Users\\Nouman\\Desktop\\Node\\camer nodejs\\proj.js'
2 'arg1' your first argument you passed.
3 'arg2' your second argument you passed.
4 'arg3' your third argument you passed.
说明:
C:\\Program Files\\nodejs\\node.exe
)proj.js
)arg1
)的第一个参数arg2
)的第二个参数arg3
) 您的实际参数从argv
数组的第二个索引开始,即process.argv[2]
。
const args = process.argv.slice(2).reduce((acc, arg) => {
let [k, v = true] = arg.split('=')
acc[k] = v
return acc
}, {})
对于此命令node index.js count=2 print debug=false msg=hi
console.log(args) // { count: '2', print: true, debug: 'false', msg: 'hi' }
我们可以改变
let [k, v = true] = arg.split('=')
acc[k] = v
通过(更长的时间)
let [k, v] = arg.split('=')
acc[k] = v === undefined ? true : /true|false/.test(v) ? v === 'true' : /[\d|\.]+/.test(v) ? Number(v) : v
自动解析布尔值和数字
console.log(args) // { count: 2, print: true, debug: false, msg: 'hi' }
传递、解析参数是一个简单的过程。 Node 为您提供 process.argv 属性,它是一个字符串数组,是调用 Node 时使用的参数。 数组的第一个条目是 Node 可执行文件,第二个条目是脚本的名称。
如果您使用以下参数运行脚本
$ node args.js arg1 arg2
文件:args.js
console.log(process.argv)
你会得到像
['node','args.js','arg1','arg2']
使用nconf https://github.com/flatiron/nconf之类的集中方式来管理您的配置可能是一个好主意
它可以帮助您使用配置文件,环境变量,命令行参数。
在节点代码中需要内置的进程库。
const {argv} = require('process')
使用他们的 arguments 运行程序。
$ node process-args.js one two=three four
argv 是后面的数组:
argv[0] = /usr/bin/node
argv[1] = /home/user/process-args.js
argv[2] = one
argv[3] = two=three
argv[4] = four
npm install ps-grab
node greeting.js --user Abdennour --website http://abdennoor.com
——
var grab=require('ps-grab');
grab('--username') // return 'Abdennour'
grab('--action') // return 'http://abdennoor.com'
或类似的东西:
node vbox.js -OS redhat -VM template-12332 ;
——
var grab=require('ps-grab');
grab('-OS') // return 'redhat'
grab('-VM') // return 'template-12332'
您可以使用system.args
访问命令行参数。 我使用下面的解决方案将参数解析为一个对象,这样我就可以通过名称获得我想要的那个。
var system = require('system');
var args = {};
system.args.map(function(x){return x.split("=")})
.map(function(y){args[y[0]]=y[1]});
现在您不需要知道参数的索引。 像args.whatever
一样使用它
注意:你应该使用像
file.js x=1 y=2
这样的命名参数来使用这个解决方案。
您可以解析所有参数并检查它们是否存在。
文件:解析-cli-arguments.js:
module.exports = function(requiredArguments){
var arguments = {};
for (var index = 0; index < process.argv.length; index++) {
var re = new RegExp('--([A-Za-z0-9_]+)=([A/-Za-z0-9_]+)'),
matches = re.exec(process.argv[index]);
if(matches !== null) {
arguments[matches[1]] = matches[2];
}
}
for (var index = 0; index < requiredArguments.length; index++) {
if (arguments[requiredArguments[index]] === undefined) {
throw(requiredArguments[index] + ' not defined. Please add the argument with --' + requiredArguments[index]);
}
}
return arguments;
}
不仅仅是做:
var arguments = require('./parse-cli-arguments')(['foo', 'bar', 'xpto']);
传递参数很容易,接收它们只是读取 process.argv 数组 Node 基本上可以从任何地方访问的问题。 但是您肯定希望将它们作为键/值对来读取,因此您需要编写一段脚本来解释它。
Joseph Merdrignac 发布了一个使用 reduce 的漂亮的,但它依赖于key=value
语法而不是-k value
和--key value
。 为了使用第二个标准,我将它改写得更丑、更久,我将其作为答案发布,因为它不适合作为评论。 但它确实完成了工作。
const args = process.argv.slice(2).reduce((acc,arg,cur,arr)=>{
if(arg.match(/^--/)){
acc[arg.substring(2)] = true
acc['_lastkey'] = arg.substring(2)
} else
if(arg.match(/^-[^-]/)){
for(key of arg.substring(1).split('')){
acc[key] = true
acc['_lastkey'] = key
}
} else
if(acc['_lastkey']){
acc[acc['_lastkey']] = arg
delete acc['_lastkey']
} else
acc[arg] = true
if(cur==arr.length-1)
delete acc['_lastkey']
return acc
},{})
使用此代码,命令node script.js alpha beta -charlie delta --echo foxtrot
将为您提供以下对象
args = {
"alpha":true,
"beta":true,
"c":true,
"h":true,
"a":true,
"r":true
"l":true,
"i":true,
"e":"delta",
"echo":"foxtrot"
}
如果您想在 vanilla JS/ES6 中执行此操作,您可以使用以下解决方案
仅适用于NodeJS > 6
const args = process.argv
.slice(2)
.map((val, i)=>{
let object = {};
let [regexForProp, regexForVal] = (() => [new RegExp('^(.+?)='), new RegExp('\=(.*)')] )();
let [prop, value] = (() => [regexForProp.exec(val), regexForVal.exec(val)] )();
if(!prop){
object[val] = true;
return object;
} else {
object[prop[1]] = value[1] ;
return object
}
})
.reduce((obj, item) => {
let prop = Object.keys(item)[0];
obj[prop] = item[prop];
return obj;
}, {});
而这个命令
node index.js host=http://google.com port=8080 production
将产生以下结果
console.log(args);//{ host:'http://google.com',port:'8080',production:true }
console.log(args.host);//http://google.com
console.log(args.port);//8080
console.log(args.production);//true
ps 如果您找到更优雅的解决方案,请更正 map 和 reduce 函数中的代码,谢谢;)
虽然上面的答案很完美,而且有人已经建议了 yargs,但使用这个包真的很容易。 这是一个很好的包,它使向命令行传递参数变得非常容易。
npm i yargs
const yargs = require("yargs");
const argv = yargs.argv;
console.log(argv);
请访问https://yargs.js.org/了解更多信息。
没有库的 TypeScript 解决方案:
interface IParams {
[key: string]: string
}
function parseCliParams(): IParams {
const args: IParams = {};
const rawArgs = process.argv.slice(2, process.argv.length);
rawArgs.forEach((arg: string, index) => {
// Long arguments with '--' flags:
if (arg.slice(0, 2).includes('--')) {
const longArgKey = arg.slice(2, arg.length);
const longArgValue = rawArgs[index + 1]; // Next value, e.g.: --connection connection_name
args[longArgKey] = longArgValue;
}
// Shot arguments with '-' flags:
else if (arg.slice(0, 1).includes('-')) {
const longArgKey = arg.slice(1, arg.length);
const longArgValue = rawArgs[index + 1]; // Next value, e.g.: -c connection_name
args[longArgKey] = longArgValue;
}
});
return args;
}
const params = parseCliParams();
console.log('params: ', params);
输入: ts-node index.js -p param --parameter parameter
输出: { p: 'param ', parameter: 'parameter' }
在 Node.js 中检索参数的最简单方法是通过 process.argv 数组。 这是一个全局对象,您无需导入任何其他库即可使用它。 您只需要将参数传递给 Node.js 应用程序,就像我们之前展示的那样,并且可以通过 process.argv 数组在应用程序中访问这些参数。
process.argv 数组的第一个元素将始终是指向节点可执行文件的文件系统路径。 第二个元素是正在执行的 JavaScript 文件的名称。 第三个元素是用户实际传递的第一个参数。
'use strict';
for (let j = 0; j < process.argv.length; j++) {
console.log(j + ' -> ' + (process.argv[j]));
}
这个脚本所做的就是遍历 process.argv 数组并打印索引以及存储在这些索引中的元素。 如果您质疑您收到的参数以及顺序,这对于调试非常有用。
您还可以使用像 yargs 这样的库来处理 commnadline 参数。
const process = require( 'process' );
const argv = key => {
// Return true if the key exists and a value is defined
if ( process.argv.includes( `--${ key }` ) ) return true;
const value = process.argv.find( element => element.startsWith( `--${ key }=` ) );
// Return null if the key does not exist and a value is not defined
if ( !value ) return null;
return value.replace( `--${ key }=` , '' );
}
输出:
node app.js
调用,则argv('foo')
将返回null
node app.js --foo
调用,则argv('foo')
将返回true
node app.js --foo=
调用,则argv('foo')
将返回''
node app.js --foo=bar
调用,则argv('foo')
将返回'bar'
NodeJS 公开了一个名为process
的全局变量。
我们可以用:
process.argv
获取命令行 arguments 传递给我们的脚本。
process.argv
的 output 将是一个按以下顺序排列的列表:
[
full-path-to-node-executable,
full-path-to-the-script-file
...additonal-arguments-we-provide
]
process.argv
是您的朋友,Node JS 本身支持捕获命令行参数。 请参阅下面的示例::
process.argv.forEach((val, index) => {
console.log(`${index}: ${val}`);
})
ES6 风格的无依赖解决方案:
const longArgs = arg => {
const [ key, value ] = arg.split('=');
return { [key.slice(2)]: value || true }
};
const flags = arg => [...arg.slice(1)].reduce((flagObj, f) => ({ ...flagObj, [f]: true }), {});
const args = () =>
process.argv
.slice(2)
.reduce((args, arg) => ({
...args,
...((arg.startsWith('--') && longArgs(arg)) || (arg[0] === '-' && flags(arg)))
}), {});
console.log(args());
我扩展了getArgs
函数只是为了获取命令,以及标志( -f
, --anotherflag
)和命名参数( --data=blablabla
):
/**
* @module getArgs.js
* get command line arguments (commands, named arguments, flags)
*
* @see https://stackoverflow.com/a/54098693/1786393
*
* @return {Object}
*
*/
function getArgs () {
const commands = []
const args = {}
process.argv
.slice(2, process.argv.length)
.forEach( arg => {
// long arg
if (arg.slice(0,2) === '--') {
const longArg = arg.split('=')
const longArgFlag = longArg[0].slice(2,longArg[0].length)
const longArgValue = longArg.length > 1 ? longArg[1] : true
args[longArgFlag] = longArgValue
}
// flags
else if (arg[0] === '-') {
const flags = arg.slice(1,arg.length).split('')
flags.forEach(flag => {
args[flag] = true
})
}
else {
// commands
commands.push(arg)
}
})
return { args, commands }
}
// test
if (require.main === module) {
// node getArgs test --dir=examples/getUserName --start=getUserName.askName
console.log( getArgs() )
}
module.exports = { getArgs }
$ node lib/getArgs test --dir=examples/getUserName --start=getUserName.askName
{
args: { dir: 'examples/getUserName', start: 'getUserName.askName' },
commands: [ 'test' ]
}
$ node lib/getArgs --dir=examples/getUserName --start=getUserName.askName test tutorial
{
args: { dir: 'examples/getUserName', start: 'getUserName.askName' },
commands: [ 'test', 'tutorial' ]
}
您可以从process.argv()获取命令行信息
而且我不想将问题限制在node.js
。 相反,我想把它变成如何将字符串解析为参数。
console.log(ArgumentParser(`--debug --msg="Hello World" --title="Test" --desc=demo -open --level=5 --MyFloat=3.14`))
输出
{
"debug": true,
"msg": "Hello World",
"title": "Test",
"desc": "demo",
"open": true,
"level": 5,
"MyFloat": 3.14
}
纯javascript,不需要依赖
// 👇 Below is Test (() => { window.onload = () => { const testArray = [ `--debug --msg="Hello World" --title="Test" --desc=demo -open --level=5 --MyFloat=3.14`, ] for (const testData of testArray) { try { const obj = ArgumentParser(testData) console.log(obj) } catch (e) { console.error(e.message) } } } })() // 👇 Script class ParserError extends Error { } function Cursor(str, pos) { this.str = str this.pos = pos this.MoveRight = (step = 1) => { this.pos += step } this.MoveToNextPara = () => { const curStr = this.str.substring(this.pos) const match = /^(?<all> *--?(?<name>[a-zA-Z_][a-zA-Z0-9_]*)(=(?<value>[^-]*))?)/g.exec(curStr) // https://regex101.com/r/k004Gv/2 if (match) { let {groups: {all, name, value}} = match if (value !== undefined) { value = value.trim() if (value.slice(0, 1) === '"') { // string if (value.slice(-1) !== '"') { throw new ParserError(`Parsing error: '"' expected`) } value = value.slice(1, -1) } else { // number or string (without '"') value = isNaN(Number(value)) ? String(value) : Number(value) } } this.MoveRight(all.length) return [name, value ?? true] // If the value is undefined, then set it as ture. } throw new ParserError(`illegal format detected. ${curStr}`) } } function ArgumentParser(str) { const obj = {} const cursor = new Cursor(str, 0) while (1) { const [name, value] = cursor.MoveToNextPara() obj[name] = value if (cursor.pos === str.length) { return obj } } }
Nodejs 团队在版本 18.3.0 和 16.17.0 中添加了util.parseArgs
function。 因此,如果您使用这些或更高版本的 nodejs,则可以使用此本机解决方案解析命令行 arguments。
文档中的用法示例:
const {parseArgs} = require('node:util');
const args = process.argv;
const options = {
foo: {
type: 'boolean',
short: 'f'
},
bar: {
type: 'string'
}
};
const {
values,
positionals
} = parseArgs({ args, options, allowPositionals: true });
console.log(values);
console.log(positionals);
Output 样本:
$ node parseargs.js -f --bar b
[Object: null prototype] { foo: true, bar: 'b' }
[
'/Users/mbelsky/.nvm/versions/node/v18.12.1/bin/node',
'/Users/mbelsky/parseargs.js'
]
如节点文档中所述 process.argv 属性返回一个数组,其中包含启动 Node.js 进程时传递的命令行参数。
例如,假设 process-args.js 有以下脚本:
// print process.argv
process.argv.forEach((val, index) => {
console.log(`${index}: ${val}`);
});
以如下方式启动 Node.js 进程:
$ node process-args.js one two=three four
将生成输出:
0: /usr/local/bin/node
1: /Users/mjr/work/node/process-args.js
2: one
3: two=three
4: four
大多数人都给出了很好的答案。 我也想在这里贡献一些东西。 我正在使用lodash
库提供答案,以遍历我们在启动应用程序时传递的所有命令行参数:
// Lodash library
const _ = require('lodash');
// Function that goes through each CommandLine Arguments and prints it to the console.
const runApp = () => {
_.map(process.argv, (arg) => {
console.log(arg);
});
};
// Calling the function.
runApp();
要运行上面的代码,只需运行以下命令:
npm install
node index.js xyz abc 123 456
结果将是:
xyz
abc
123
456
将命令行参数传递给Node.js程序的最佳方法是使用命令行界面(CLI)
您可以使用一个漂亮的npm模块,称为nodejs-cli 。
如果您想创建一个没有依赖性的程序,我想在Github上创建一个程序,如果您想查看它,它实际上非常简单易用,请单击此处 。
如果你想使用像server -f fileURI
这样的 unix 样式标志,那么使用server -f fileURI
的ray-fs
库。 它非常容易使用!
最初的问题是要求传递命令行参数,而不是更复杂的参数解析。 然而,对于所有复杂的答案,他们都错过了一个简单而有用的变化。
您知道 Unix shell 支持命名参数吗? 这可以追溯到 1980 年代的原始 Bourne shell。 用法很简单:
$ FOO=one BAR=two nodejs myscript.js
在 Javascript 中获取参数:
var foo = process.env.FOO;
var bar = process.env.BAR;
一旦超过两个或三个参数,命名参数就更容易阅读。 可选参数简单,顺序不固定。
(这甚至可能适用于 Windows,因为最近支持 Unix shell。)
此外,令人震惊的是,很少有 Unix 程序员知道这种用法。 :)
一个简单的片段,如果有的话需要它:
var fs = require('fs'), objMod = {};
process.argv.slice(2).map(function(y, i) {
y = y.split('=');
if (y[0] && y[1]) objMod[y[0]] = y[1];
else console.log('Error in argument number ' + (i+1));
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.