Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在手机间隙应用程序中使用连接插件来检查连接类型。它在所有经过测试的语言(eng、her、fr、es 和其他一些常见语言)中都可以正常工作,但是当我的 android 设备中的语言设置为土耳其语时,它无法返回连接类型。
有什么想法导致这个问题(以及如何解决)?
细节:
var isWifi = navigator.connection.type === Connection.WIFI;
预计是真的,但在土耳其语connection.type中是unknown
connection.type
unknown
Connection 插件实现中存在一个错误:
type.toLowerCase().equals(WIFI)
wheretype是ConnectionType从 Android API 获得的,WIFI是一个常量。在土耳其语type.toLowerCase()中,返回 'wıfı' 中的 'i' 字母与 const 中的字母不匹配。
type
ConnectionType
WIFI
type.toLowerCase()
解决方案:
将检查条件更改为:
type.equalsIgnoreCase(WIFI)