English
Get the current account information and return the Appid of the MiniApp. If the cloud plug-in of the WeChat MiniApp is used, the current plug-in Appid and version number can also be returned.
Platform Difference Description
| App | H5 | 微信小程序 | 支付宝小程序 | 百度小程序 | 抖音小程序、飞书小程序 | QQ小程序 | 快手小程序 | 京东小程序 | 元服务 | 小红书小程序 |
|---|---|---|---|---|---|---|---|---|---|---|
| x | x | √ | √ | x | x | √ | √ | √ | x | √ |
return value
Object
account information
| Property | Type | Description | Platform Difference Description |
|---|---|---|---|
| miniProgram | Object | 小程序帐号信息 | |
| plugin | Object | 插件帐号信息(仅在插件中调用时包含这一项) | 京东、快手小程序、小红书小程序不支持 |
The structure of the miniProgram
| Property | Type | Description | Platform Difference Description |
|---|---|---|---|
| appId | string | MiniApp appId | |
| envVersion | string | The current environment version of the MiniApp: develop development version, trial trial version, release official version, gray grayscale version (only supported by Alipay MiniApp) | Jingdong MiniApp not support |
| version | string | The version number of the online MiniApp(only supported on the official version of the MiniApp) | Jingdong MiniApp not support |
plugin structure
| property | type | description |
|---|---|---|
| appId | string | plugin appId |
| version | string | Plugin version number |
Sample code
const accountInfo = uni.getAccountInfoSync();
console.log(accountInfo.miniProgram.appId); // 小程序 appId
console.log(accountInfo.plugin.appId); // 插件 appId
console.log(accountInfo.plugin.version); // 插件版本号, 'a.b.c' 这样的形式