参考文档1:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-net-connection-V5\#connectiongetallnetssync10判断返回的数组元素个数大于0就可以得到当前是否连接到网络参考文档2:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-net-connection-V5\#connectiongetnetcapabilitiesnetcap参数为12 16 是网络可用
参考文档1:
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-net-connection-V5\#connectiongetallnetssync10
判断返回的数组元素个数大于0就可以得到当前是否连接到网络
参考文档2:
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-net-connection-V5\#connectiongetnetcapabilities
netcap参数为12 16 是网络可用