WeChat Open Platform

Mini Programs Documentation

System Info

wx.getSystemInfo(OBJECT)

Gets system information.

OBJECT parameter descriptions:

Parameter Type Required Description
success Function Yes Callback for successful interface call
fail Function No Callback function for failed interface call
complete Function No Callback function for interface call results (will be executed if call succeeds or fails)

success callback parameter descriptions:

Parameter Description Minimum version
model Phone model
pixelRatio Device pixel ratio
screenWidth Screen width
screenHeight Screen height
windowWidth Usable window width
windowHeight Usable window height
language Language set in WeChat
version WeChat version number
system Operating system version
platform Client platform
SDKVersion Client base library version

Sample code:

wx.getSystemInfo({
  success: function(res) {
    console.log(res.model)
    console.log(res.pixelRatio)
    console.log(res.windowWidth)
    console.log(res.windowHeight)
    console.log(res.language)
    console.log(res.version)
    console.log(res.platform)
  }
})

wx.getSystemInfoSync()

Gets system information synchronization interface.

Synchronous return parameter descriptions:

Parameter Description Minimum version
model Phone model
pixelRatio Device pixel ratio
screenWidth Screen width
screenHeight Screen height
windowWidth Usable window width
windowHeight Usable window height
language Language set in WeChat
version WeChat version number
system Operating system version
platform Client platform
SDKVersion Client base library version

Sample code:

try {
  var res = wx.getSystemInfoSync()
  console.log(res.model)
  console.log(res.pixelRatio)
  console.log(res.windowWidth)
  console.log(res.windowHeight)
  console.log(res.language)
  console.log(res.version)
  console.log(res.platform)
} catch (e) {
  // Do something when catch error
}