2017-08-02 46 views

回答

1

最后navigator.permissions.query会支持这个。来自Web Bluetooth Specification的示例代码

navigator.permissions.query({ 
    name: "bluetooth", 
    deviceId: sessionStorage.lastDevice, 
}).then(result => { 
    if (result.devices.length == 1) { 
    return result.devices[0]; 
    } else { 
    throw new DOMException("Lost permission", "NotFoundError"); 
    } 
}).then(...); 

但是,no browser currently implements this

Q3 2017开始,铬的实现在积极地处理Web蓝牙,但没有这个功能。