基础库 2.33.0 开始支持,低版本需做兼容处理。
以 Promise 风格 调用:不支持
微信小程序插件:不支持
微信 Windows 版:支持
微信 Mac 版:支持
微信 鸿蒙 OS 版:支持
功能描述
传入实验参数数组,就能获取到对应的实验参数值。
参数
Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| keys | Array.<string> | 否 | 需要获取的数据指标的对象数组,每个 string 的格式约定为:配置类型_分表key | |
| mode | number | 是 | 0:通用配置模式 1:实验模式,参数与返回结果的使用等同于接口 wx.getExptInfoSync | |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
object.success 回调函数
参数
Object res
| 属性 | 类型 | 说明 |
|---|---|---|
| errcode | number | 错误码 |
| errmsg | string | 错误信息 |
| conf_type | number | 配置类型,1-表类型 2-kv类型 |
| conf | string | 根据 conf_type 来确定 conf 的内容。conf_type 为 1 时,conf 是一个 json 数组,类似 “[{xxx},{xxx}]”,每一项对应表类型中每一行的配置内容;conf_type 为 2 时,conf 是一个 json 对象,类似 “{xxxx}” |
| expire_sec | number | 过期时间,单位秒。0 表示当次有效 |
示例代码
wx.getCommonConfig({
keys:["key1", "key2"],
mode: 0,
success: (res)=>{
console.log("success")
console.log(res)
},
fail: (res)=>{
console.log("fail")
console.log(res)
}})