|
没有用CI框架是能正常工作的, 用了之后报错
serial.js:7 Uncaught TypeError: Cannot read property 'getDevices' of undefined
at Object.serial.getPorts (serial.js:7)
at HTMLDocument.document.addEventListener.event (rgb.js:87)
'getDevices' 是chrome内部的API,
代码如下
var serial = {};
(function() {
'use strict';
serial.getPorts = function() {
return navigator.usb.getDevices().then(devices => {
return devices.map(device => new serial.Port(device));
});
}; |
|