我使用 CLI 添加了蓝牙插件,并将以下代码添加到 index.html。但这是行不通的。我是 phonegap 的新手。请帮助包括这个插件。我使用了 tanelign-bluetooth 插件。
<script>
window.bluetooth.pair(
function() {
alert('Pairing Successful');
},
function(err) {
alert('There was an error Pairing to a device'+ JSON.stringify(err));
}, deviceaddress);
最佳答案
您需要先在设备就绪事件中添加:
document.addEventListener("deviceready", yourCallbackFunction, false);
function yourCallbackFunction(){
window.bluetooth = cordova.require("cordova/plugin/bluetooth");
}
然后在您的页面中添加此 js: https://github.com/tanelih/phonegap-bluetooth-plugin/tree/master/www
像这样:<script src="bluetooth.js"></script>
关于android - 如何添加phonegap蓝牙插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33327667/