cmp.connection 类
网络
方法
getNetworkDetail
getNetworkDetail
(
-
options
)
获取当前网络详情
参数:
名称 | 类型 | 标识 | 描述 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options
| Object | 必选 | 配置参数
|
示例:
文件导入路径:
M3App端
<script src="http://cmp/v1.0.0/js/cordova/__CMPSHELL_PLATFORM__/cordova.js"></script>
<script src="http://cmp/v1.0.0/js/cordova/cordova-plugins.js"></script>
<script src="http://cmp/v/js/cmp.js"></script>
<script src="http://cmp/v/js/cmp-connection.js"></script>
===========================================================================================
微协同端:不支持
=========================================================================================
调用组件
<script>
cmp.connection.getNetworkDetail({
success:function(networkDetail){
//do something with networkDetail
}
});
</script>
getNetworkType
getNetworkType
(
-
options
)
String
获取当前网络类型
参数:
名称 | 类型 | 标识 | 描述 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options
| Object | 必选 | 配置参数
|
返回值:
[String]
networkState 类型有:
- Unknown:未知网络
- Ethernet:以太网
- wifi:wifi
- 2g:2g网络
- 3g:3g网络
- 4g:4g网络
- generic:未受保护的通用网络
- NONE:没有网络
示例:
文件导入路径:
M3App端
<script src="http://cmp/v1.0.0/js/cordova/__CMPSHELL_PLATFORM__/cordova.js"></script>
<script src="http://cmp/v1.0.0/js/cordova/cordova-plugins.js"></script>
<script src="http://cmp/v/js/cmp.js"></script>
<script src="http://cmp/v/js/cmp-connection.js"></script>
===========================================================================================
微协同端:
<script src="/seeyon/m3/cmp/js/cmp.js"></script>
<script src="/seeyon/m3/cmp/js/cmp-connection.js"></script>
=========================================================================================
调用组件
<script>
cmp.connection.getNetworkType({
success:function(networkState){
//返回的数据格式,请参考下面return的类型
//do something with networkState
}
});
</script>