Skip to content

Commit 8183ed4

Browse files
committed
优化 init 代码,修正变量名。
1 parent 5e0a7f3 commit 8183ed4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/utils.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,26 @@ module.exports = function(AV) {
103103
* @param {Object} incloud appId, appKey, masterKey
104104
*/
105105

106-
AV.init = (...options) => {
107-
switch (options.length) {
106+
AV.init = (...args) => {
107+
switch (args.length) {
108108
case 1:
109+
const options = args[0];
109110
if (typeof options === 'object') {
110111
if (!AV._config.isNode && options.masterKey) {
111112
throw new Error('AV.init(): Master Key is only used in Node.js.');
112113
}
113-
initialize(options[0].appId, options[0].appKey, options[0].masterKey);
114+
initialize(options.appId, options.appKey, options.masterKey);
114115
} else {
115116
throw new Error('AV.init(): Parameter is not correct.');
116117
}
117118
break;
118119
// 兼容旧版本的初始化方法
119120
case 2:
120121
case 3:
121-
if (!AV._config.isNode && options.length === 3) {
122+
if (!AV._config.isNode && args.length === 3) {
122123
throw new Error('AV.init(): Master Key is only used in Node.js.');
123124
}
124-
initialize(...options);
125+
initialize(...args);
125126
break;
126127
}
127128
};

0 commit comments

Comments
 (0)