我正在使用网络信息 API来获取网络类型。
var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
// output in Microsoft edge browser console
// {onchange: null, effectiveType: "4g", rtt: 100, downlink: 1.5, saveData: false}
我正在使用公司的 wifi 网络。我预计effectiveType
财产的价值应该是wifi
。因为我有一些这样的代码逻辑:
if(effectiveType === 'wifi') {
// Do something
} else if (effectiveType === '4g') {
// Do other things
}
那可能吗?我找到了NetworkInformation.type只读属性,但它给了我undefined
. 它不支持边缘。
我看到EffectiveConnectionType 枚举没有wifi
价值。
环境:
- macOS 10.15.7
- 微软边缘 89.0.774.63