2.1.1 • Published 3 years ago

frondend-config v2.1.1

Weekly downloads
6
License
-
Repository
-
Last release
3 years ago

前端配置

1、环境参数文件设置frondendConfigUrl

# .env.development示例
frondendConfigUrl=/xxx/frondend-config.json

# .env.production示例
frondendConfigUrl=http://xxx.xxx.xxx.xxx:xxx/xxx/frondendConfig

2、加载配置,依次加载地址列表中的配置,前面的配置优先于后面的配置

import frondendConfig from 'frondend-config'
frondendConfig.load(process.env.frondendConfigUrl).then(function (frondendConfig) {
    // 加载完成,配置保存在frondendConfig
    // TODO: 加载业务
}).catch(function (error) {
    // 异常处理
    console.log(error)
})

3、其它文件使用配置

import frondendConfig from 'frondend-config'
// 配置保存在frondendConfig