ionic判断当前网络状态
2016-11-21 本文已影响0人
Android10
/****
* 当前的连接状态
*/
var networkState = $cordovaNetwork.getNetwork();
if(networkState == Connection.NONE){
alert('没有网络连接');
} else if(Connection.CELL_2G == networkState || Connection.CELL_3G == networkState || Connection.CELL_4G == networkState){
alert('使用流量连接');
} else if(Connection.WIFI == networkState){
alert('使用wifi连接');
} else if(Connection.ETHERNET == networkState){
alert('使用以太网');
}