Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program device


May 19, 2021 WeChat Mini Program Development Document


Table of contents


An overview of WeChat's small program API devices

wx.getSystemInfo(OBJECT)


Get system information.

OBJECT parameter description:

Parameters Type Required Description
success Function Is The interface calls a successful callback
fail Function Whether The interface calls the failed callback function
complete Function Whether Callback function at end of interface call (call succeeds, fails are executed)

Description of the success callback parameters:

Property Description
model Mobile phone model
pixelRatio The device pixel ratio
windowWidth The width of the window
windowHeight The height of the window
language The language set by WeChat
version WeChat version number
system The operating system version
platform The client platform

Example 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()


Get the system information synchronization interface

Example 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
}