aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/orphaned/web/api/devicelightevent/index.html
blob: e3e717c51417c0addba1a399b694c9872104d8f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
title: DeviceLightEvent
slug: orphaned/Web/API/DeviceLightEvent
tags:
  - API
  - Ambient Light Events
  - Experimental
  - Interface
  - NeedsBetterSpecLink
  - NeedsMarkupWork
  - 事件
translation_of: Web/API/DeviceLightEvent
original_slug: Web/API/DeviceLightEvent
---
<div>{{apiref("Ambient Light Events")}}{{SeeCompatTable}}</div>

<p><code>DeviceLightEvent</code> 为 Web 开发人员提供来自光传感器或类似设备的、关于附近环境光水平的信息。例如,基于当前环境光水平调节屏幕的亮度,以便节省电量或提供更好的阅读性。</p>

<h2 id="属性">属性</h2>

<dl>
 <dt>{{domxref("DeviceLightEvent.value")}}</dt>
 <dd>环境光的亮度,单位为 {{interwiki("wikipedia", "lux")}}</dd>
</dl>

<h2 id="示例">示例</h2>

<pre class="brush: js">window.addEventListener('devicelight', function(event) {
  console.log(event.value);
});</pre>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">规范</th>
   <th scope="col">状态</th>
   <th scope="col">备注</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{ SpecName('AmbientLight', '', 'Ambient Light Events') }}</td>
   <td>{{ Spec2('AmbientLight') }}</td>
   <td>Initial specification</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>



<p>{{Compat("api.DeviceLightEvent")}}</p>

<h2 id="参见">参见</h2>

<ul>
 <li>{{ event("devicelight") }}</li>
 <li><a href="/zh-CN/docs/WebAPI/Using_Light_Events">使用环境光事件</a></li>
</ul>