【发布时间】:2017-08-17 20:53:12
【问题描述】:
参考本期:How to make the Web Bluetooth Pair button work when run as chrome app
在我的测试中,调用 navigator.bluetooth.requestDevice 时弹出的窗口非常大,完全覆盖了调用它的 html 窗口,并且包含 Pair 和 Cancel 按钮的窗口底部已关闭屏幕底部,因此不可见。
requestDevice窗口是否可以控制和定位?
<html>
<head>
<script type="text/javascript" src="bluetoothle.js"></script>
<script type="text/javascript" src="popup.js"></script>
</head>
<body>
<h1>Hello Bluetooth</h1>
<h2>Device Discovery</h2>
<button id="btn_discover">Discover Devices</button>
<div id="devices"></div>
</body>
</html>
navigator.bluetooth.requestDevice(options)
.then(device => {
console.log('> Name: ' + device.name);
console.log('> Id: ' + device.id);
console.log('> Connected: ' + device.gatt.connected);
bluetoothle.selected_device = device;
console.log(bluetoothle.selected_device);
})
.catch(error => {
console.log('ERROR: '+ error);
});
【问题讨论】:
标签: web-bluetooth