【发布时间】:2019-05-23 05:52:00
【问题描述】:
如果我从http://localhost 提供我的应用程序,我可以在开发控制台中使用window.navigator.storage.estimate()。
如果我从http://example.com 提供相同的应用程序,其中example.com 从我的/etc/hosts 解析为127.0.0.1,则window.navigator 未定义。
怎么会?
(铬是 71)
【问题讨论】:
-
This feature is available only in secure contexts但对于 localhost 来说可能没问题,因为它通常用于开发目的。 -
@Keith 你是对的。在挖掘时,我发现 Chrome 认为 localhost 是一个安全的上下文。随意发布这个作为答案。
标签: javascript google-chrome local-storage