get-extconfig.md 1.6 KB
Newer Older
M
mehaotian 已提交
1 2 3 4 5 6 7 8
### uni.getExtConfig(OBJECT)

获取第三方平台自定义的数据字段。

**平台差异说明**

|5+App|H5|微信小程序|支付宝小程序|百度小程序|头条小程序|
|:-:|:-:|:-:|:-:|:-:|:-:|
9
|x|x|√|x|√|√|
M
mehaotian 已提交
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

**OBJECT参数说明**

| 属性 | 类型 | 默认值 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| success | function |  | 否 | 接口调用成功的回调函数 |
| fail | function |  | 否 | 接口调用失败的回调函数 |
| complete | function |  | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |

**success 回调参数说明**

| 属性 | 类型 | 说明 |
| --- | --- | --- |
| extConfig | Object | 第三方平台自定义的数据 |

**Tips**

* 本接口暂时无法通过 `uni.canIUse`判断是否兼容,开发者需要自行判断 `uni.getExtConfig` 是否存在来兼容。

**示例代码**

```
if (uni.getExtConfig) {
  uni.getExtConfig({
    success(res) {
      console.log(res.extConfig)
    }
  })
}
```


### uni.getExtConfigSync()

``uni.getExtConfig`` 的同步版本。

**平台差异说明**

|5+App|H5|微信小程序|支付宝小程序|百度小程序|头条小程序|
|:-:|:-:|:-:|:-:|:-:|:-:|
50
|x|x|√|x|√|√|
M
mehaotian 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

**返回值(Object)**

| 属性 | 类型 | 说明 |
| --- | --- | --- |
| extConfig | Object | 第三方平台自定义的数据 |

**Tips**

* 本接口暂时无法通过 `uni.canIUse`判断是否兼容,开发者需要自行判断 `uni.getExtConfigSync` 是否存在来兼容。

**代码示例**

```
const extConfig = uni.getExtConfigSync ? uni.getExtConfigSync() : {}
console.log(extConfig)
```