# wx.onNetworkStatusChange(function callback)
Start from base library version 1.1.0. Please remaining backward compatible.
with Promise style call: Not supported
Mini Program plugin: Support
Monitor Network State Change Event
# parameter
# function callback
Callback function for network state change events
# parameter
# Object object
attribute | type | Introductions |
---|---|---|
isConnected | boolean | Are you currently connected to a network? |
networkType | string | Network type |
networkType Legal value
value | Introductions | Minimum version |
---|---|---|
wifi | wifi network | |
2g | 2g network | |
3g | 3g network | |
4g | 4g network | |
unknown | Android Less common network types under | |
none | No network |
# sample code
wx.onNetworkStatusChange(function (res) {
console.log(res.isConnected)
console.log(res.networkType)
})