DevicePosture: thuộc tính type
Khả dụng hạn chế
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Thuộc tính chỉ đọc type của giao diện DevicePosture trả về tư thế hiện tại của thiết bị.
Giá trị
Một chuỗi đại diện cho tư thế hiện tại của thiết bị. Giá trị có thể là một trong các giá trị sau:
continuous-
Chỉ ra tư thế màn hình phẳng, bao gồm thiết bị có thể gập khi đang sử dụng ở dạng phẳng, màn hình cong liền mạch, hoặc màn hình máy tính để bàn, laptop, máy tính bảng hoặc điện thoại thông thường.
folded-
Chỉ ra tư thế màn hình gập, bao gồm thiết bị có thể gập đang được sử dụng ở dạng sách hoặc laptop.
Ví dụ
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);
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Device Posture API> # dom-deviceposture-type> |
Tương thích trình duyệt
Xem thêm
- CSS
device-posture@mediafeature - Device Posture API
- Origin trial for Foldable APIs on developer.chrome.com (2024)