ScreenDetailed: thuộc tính devicePixelRatio

Limited availability

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.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Thuộc tính chỉ đọc devicePixelRatio của giao diện ScreenDetailed là một số đại diện cho tỷ lệ device pixel của màn hình.

Giá trị này giống với giá trị trả về bởi Window.devicePixelRatio, ngoại trừ Window.devicePixelRatio:

  • luôn trả về tỷ lệ pixel thiết bị của màn hình hiện tại.
  • cũng bao gồm hệ số thu phóng của cửa sổ, tức là thu phóng trang (ít nhất trong một số triển khai trình duyệt).

Giá trị

Một số.

Ví dụ

js
const screenDetails = await window.getScreenDetails();

// Return the device pixel ratio of the first screen
const screen1DPR = screenDetails.screens[0].devicePixelRatio;

Thông số kỹ thuật

Specification
Window Management
# ref-for-dom-screendetailed-devicepixelratio

Tương thích trình duyệt

Xem thêm