May 19, 2021 WeChat Mini Program Development Document
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)
}
})
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
}