AmbientLightSensor:AmbientLightSensor() 构造函数
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
AmbientLightSensor() 构造函数用于创建一个新的 AmbientLightSensor 对象,该对象可返回宿主设备周围环境光的当前光照强度(照度)值。
语法
js
new AmbientLightSensor()
new AmbientLightSensor(options)
参数
options可选-
当前仅支持一个选项:
frequency可选-
指定每秒采样的次数,即每秒触发
reading事件的次数。该值可以是整数或小数,后者用于表示小于 1 秒的频率。实际的读取频率取决于设备硬件,因此可能低于请求的值。
异常
SecurityErrorDOMException-
此特性的使用已被权限策略阻止。
规范
| Specification |
|---|
| Ambient Light Sensor> # dom-ambientlightsensor-ambientlightsensor> |
浏览器兼容性
参见
reading事件