May 19, 2021 WeChat Mini Program Development Document
Get a network type.
Object parameter description:
parameter | type | Required | illustrate |
---|---|---|---|
success | Function | Yes | The interface call is successful, return to the network type networkType |
fail | Function | no | Interface call failed callback function |
complete | Function | no | The callback function ended in the interface call (the call is successful, failed) |
SUCCESS Return Parameter Description:
parameter | illustrate |
---|---|
networkType | Network Type |
wx.getNetworkType({
success: function(res) {
// 返回网络类型, 有效值:
// wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
var networkType = res.networkType
}
})
The base library 1.1.0 began support, low version needs to be done Compatibility 。
Listen to network status changes.
Callback returns the parameters:
parameter | type | illustrate |
---|---|---|
isConnected | Boolean | Whether there is a network connection |
networkType | String | Network Type |
NetWorktype Valid value:
value | illustrate |
---|---|
wifi | WiFi network |
2g | 2G network |
3g | 3G network |
4g | 4G network |
none | No network |
unknown | Uncommon network type under Android |
Sample code:
wx.onNetworkStatusChange(function(res) {
console.log(res.isConnected)
console.log(res.networkType)
})
Base Library 2.9.3 starts to support, and low versions need to be compatible.
Cancel all event monitoring events with empty parameters.
The callback function for network state change events