tt.onNetworkStatusChange 1.0.0+
监听网络状态变化。
输入
名称 | 数据类型 | 属性 | 默认值 | 描述 |
---|---|---|---|---|
callback | function | required | N/A | 回调函数 |
输出
callback
的参数 Object res
:
名称 | 类型 | 描述 |
---|---|---|
networkType | string | 网络类型 |
networkType 值列表
值 | 说明 |
---|---|
wifi | wifi 网络 |
2g | 2g 网络 |
3g | 3g 网络 |
4g | 4g 网络 |
unknown | Android 下不常见的网络类型 |
none | 无网络 |
代码示例
tt.onNetworkStatusChange(function(res) {
console.log(res.networkType);
});