ionic判断当前网络状态

     /****
             * 当前的连接状态
             */
            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('使用以太网');
            }

你可能感兴趣的:(ionic判断当前网络状态)