Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/383.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 插件不工作_Javascript_Cordova_Plugins_Bluetooth Lowenergy - Fatal编程技术网

Javascript 插件不工作

Javascript 插件不工作,javascript,cordova,plugins,bluetooth-lowenergy,Javascript,Cordova,Plugins,Bluetooth Lowenergy,我已经安装了Rand Dusing的BLE Cordova插件,并以他为例初始化蓝牙,但我无法通过。这是我的index.js var blePlugin=window.bluetoothle; 函数bleInitialize(){ var paramsObj={ 请求:正确, 状态接收器:真 }; document.getElementById(“BTHWStatus”).innerHTML='initialize-BLE:检查BT状态…'; 初始化(bleInitializeSuccess,

我已经安装了Rand Dusing的BLE Cordova插件,并以他为例初始化蓝牙,但我无法通过。这是我的
index.js

var blePlugin=window.bluetoothle;
函数bleInitialize(){
var paramsObj={
请求:正确,
状态接收器:真
};
document.getElementById(“BTHWStatus”).innerHTML='initialize-BLE:检查BT状态…';
初始化(bleInitializeSuccess,bleInitializeError,paramsObj);
document.getElementById(“BTHWStatus”).innerHTML='initialize-BLE:Complete';
返回false;
}
函数bleInitializeSuccess(obj){
如果(对象状态==“已启用”)
document.getElementById(“BTHWStatus”).innerHTML='BT已打开';
其他的
document.getElementById(“BTHWStatus”).innerHTML='BLE:Initialize:意外错误';
}
函数bleInitializeError(obj){
document.getElementById(“BTHWStatus”).innerHTML=“初始化错误:”+JSON.stringify(obj);

}
您的应用程序代码是否已执行?从你的代码中我看不到,所以问题可能是这个


如果您不等待
devicerady
事件,js代码将工作,但Cordova相关功能将不可用。

是的,正在执行
devicerady
之后的应用程序代码,我可以从Cordova插件设备获取设备信息(Cordova、版本、型号等),我在
devicerady
中调用这些信息。我也从deviceready调用
bleInitialize