Slide 9
Slide 9 text
代码
config(setting: any = {}): void {
__mergeEnv(setting) // 覆盖数据
}
init(key: string, ...args: any[]) {
instance.key = key
instance.args = args
try {
if (!(key && /^([a-zA-Z])/.test(key))) {
return instance._catchError(MsgConfig.call(instance, 'KEY_INPUT'))
}
const _tmpKeysArray = key.replace(/\[/g, '.').replace(/\]/g, '').split('.')
let _tmpSdk: any = instance._config.sdk
for (let item of _tmpKeysArray) {
_tmpSdk = _tmpSdk[item]
if (_tmpSdk === null || _tmpSdk === undefined) {
return instance._catchError(MsgConfig.call(instance, 'KEY_NOT_FIND'))
}
if (typeof _tmpSdk === 'function') {
return _tmpSdk(...args)
}
}
return _tmpSdk
} catch (error) {
error = Object.assign({}, MsgConfig.call(instance, 'CATCH'), {error})
return instance._catchError(error)
}
}