# wx.onNetworkStatusChange(function callback)
Start from base library version 1.1.0. Please remaining backward compatible.
Listens on the network status change event.
# Parameters
# function callback
The callback function for the network status change event.
# Parameters
# Object res
| Property | Type | Description |
|---|---|---|
| isConnected | boolean | Indicates whether it is connected to the network |
| networkType | string | Network type |
Valid values of networkType
| Value | Description | Minimum Version |
|---|---|---|
| wifi | Wi-Fi network | |
| 2g | 2G network | |
| 3g | 3G network | |
| 4g | 4G network | |
| unknown | Uncommon network types for Android | |
| none | No network |
# Sample Code
wx.onNetworkStatusChange(function (res) {
console.log(res.isConnected)
console.log(res.networkType)
})