【发布时间】:2020-10-02 14:35:27
【问题描述】:
我需要使用 webUSB 将设备连接到浏览器,连接后我调用 open 方法并且此错误属于“Uncaught (in promise) DOMException: Access denied.”。如何解决?
ngOnInit(): void {
const button = document.getElementById('connectButton');
button.addEventListener('click', async () => {
let device;
try {
device = await navigator.usb.requestDevice({ filters: []});
} catch (err) {
}
device.open()
.then(() => device.selectConfiguration(1))
.then(() => device.claimInterface(device.configuration.interfaces[0].interfaceNumber));
});
}
【问题讨论】: