当我尝试使用 Cordova 的 checkConnection
函数时,发生上述错误:
cordova.js:29 Uncaught ReferenceError : require is not defined
我做错了什么?
function checkConnection()
{
var networkState = navigator.connection.type;
var states = {};
states[Connection.UNKNOWN] = "Unknown connection";
states[Connection.ETHERNET] = "Ethernet connection";
states[Connection.WIFI] = "WiFi connection";
states[Connection.CELL_2G] = "Cell 2G connection";
states[Connection.CELL_3G] = "Cell 3G connection";
states[Connection.CELL_4G] = "Cell 4G connection";
states[Connection.CELL] = "Cell generic connection";
states[Connection.NONE] = "No network connection";
alert("Connection type: " + states[networkState]);
}
最佳答案
通过更改config.xml
中的target
和minimum-sdk
来解决
关于javascript - Cordova 连接中 Uncaught ReferenceError ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37104555/