1. Introduction to the open interface: WX.getAccountInfosync ()

Get the current account information. Online applet version number can only be obtained in the official version of applet, not in the development version and experience version.

Small program official API link

Before the official verification method was provided, the request URL had to be manually modified before going online. Now the runtime environment can be determined based on the return value of wx.getAccountInfosync (), and the request_URL can be configured automatically, with the method at the end. The downside is that you have to set the base library version.

If the user does not update the WeChat version in time, it may report an error. It is recommended to set the minimum base library.

2. Return value [Object]

(1) Account information

attribute type instructions
miniProgram Object Small program account information
plugin Object Plug-in account information (includes this only when invoked within a plug-in)

(2) Structure of MiniProgram

attribute type instructions Minimum version
appId string Small program appId
envVersion string Applet version 2.10.0
version string Online applet version number 2.10.2

(3) Structure of Plugin

attribute type instructions
appId string Plug-in appId
version string Plug-in version number

(4) The valid value of miniprogram. envVersion

value type Minimum version
develop Development version
trial Experience version
release The final version

3. Sample code

const accountInfo = wx.getAccountInfoSync(); The console. The log (accountInfo. MiniProgram. AppId) / / applet appId console. The log (accountInfo. Plugin. AppId) / / appId plug-in The console. The log (accountInfo. Plugin. Version) / / plug-in version number, 'X.X.X such form to the console. The log (accountInfo. MiniProgram. EnvVersion); // Develop the current environment