简体   繁体   中英

Access serial port in web worker

I want to access the serial port navigator.serial.requestPort() in web worker, but I get this error:

Uncaught (in promise) TypeError: navigator.serial.requestPort is not a function

How can I fix this?

You can't call requestPort from a worker, you'll need to call requestPort in the main application code then tell the worker to open the port.

See example here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM