实例属性
继承其父级 EventTarget
的属性。
type
只读 实验性-
返回设备的当前状态。
事件
change
实验性-
当设备状态发生变化时触发。
示例
js
const postureOutput = document.getElementById("currentPosture");
function reportPostureOutput() {
// type property returns "continuous" or "folded"
postureOutput.textContent = `Device posture: ${navigator.devicePosture.type}`;
}
navigator.devicePosture.addEventListener("change", reportPostureOutput);
规范
规范 |
---|
设备姿态 API # dom-deviceposture |
浏览器兼容性
加载中…
另见
- CSS
device-posture
@media
特性 - 设备姿态 API
- developer.chrome.com 上的折叠 API 来源试用 (2024)