简体   繁体   English

Chrome Web Serial API 在 VueJs Web 应用程序中不起作用

[英]Chrome Web Serial API not working in VueJs Web app

I'm developing an enterprise web app with Vue.js, and I would like to use the Web Serial API in Chrome.我正在使用 Vue.js 开发企业 Web 应用程序,我想在 Chrome 中使用 Web Serial API。 On the linux machine that I'm developing on, I went to this Chrome flag chrome://flags/#enable-experimental-web-platform-features and enabled it.在我正在开发的 linux 机器上,我转到了这个 Chrome 标志chrome://flags/#enable-experimental-web-platform-features并启用了它。 Then I did console.log('serial' in navigator) and it returned true, meaning that the flag is enabled.然后我做了console.log('serial' in navigator)并返回 true,这意味着该标志已启用。 All is good so far.到目前为止一切都很好。

So I went and did the same thing on the corporate computer I need to be using (running windows 10).所以我去我需要使用的公司计算机上做了同样的事情(运行 Windows 10)。 I enabled the flag in Chrome, restarted it, and ran console.log('serial' in navigator) on the tab running the web app, but it returns false, which is bad because I need it to be true.我在 Chrome 中启用了该标志,重新启动它,并在运行 Web 应用程序的选项卡上运行console.log('serial' in navigator) ,但它返回 false,这很糟糕,因为我需要它为 true。 But when I run that code on a different tab, it returns true.但是当我在不同的选项卡上运行该代码时,它返回 true。 How could my web app be changing the navigator?我的网络应用程序如何更改导航器? So I can't use the Web Serial API on the one computer that needs to be using it and I don't know why.所以我不能在需要使用它的一台计算机上使用 Web Serial API,我不知道为什么。

Any help is appreciated.任何帮助表示赞赏。

UPDATED.更新。 The problem is not specific from vue js, you should make the script execute from a secure environment, either localhost or from a ssl secured domain.问题不是 vue js 特有的,您应该使脚本从安全环境(本地主机或 ssl 安全域)执行。 This security concerns are covered on this draft https://wicg.github.io/serial/#security .这个安全问题包含在这个草案https://wicg.github.io/serial/#security 中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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