首页 > 解决方案 > Chrome 和网络串行 API。如何在不询问的情况下获得端口

问题描述

我需要你的帮助。

有没有办法在不使用弹出窗口的情况下控制先前授权的串行端口?(没有端口 = await navigator.serial.requestPort();

谢谢你,对不起我的英语,意大利语在这里说。

标签: google-chromeweb-serial-api

解决方案


我相信下面的 JS 代码应该适合你:

// Get all serial ports the user has previously granted the website access to.
const ports = await navigator.serial.getPorts();

来源:https ://web.dev/serial/#open-port


推荐阅读