获取屏幕信息(动态)
窗口大小可能会变化
getScreenInfo
函数签名
typescript
function getScreenInfo()描述
获取屏幕信息(动态) 窗口大小可能会变化
返回值
{ width: number; height: number; availWidth: number; availHeight: number; colorDepth: number; pixelDepth: number; devicePixelRatio: number; }
点击查看源码
js
/**
* 获取屏幕信息(动态)
* 窗口大小可能会变化
*/
export function getScreenInfo() {
return {
width: window.screen.width,
height: window.screen.height,
availWidth: window.screen.availWidth,
availHeight: window.screen.availHeight,
colorDepth: window.screen.colorDepth,
pixelDepth: window.screen.pixelDepth,
devicePixelRatio: window.devicePixelRatio || 1,
};
}ts
/**
* 获取屏幕信息(动态)
* 窗口大小可能会变化
*/
export function getScreenInfo() {
return {
width: window.screen.width,
height: window.screen.height,
availWidth: window.screen.availWidth,
availHeight: window.screen.availHeight,
colorDepth: window.screen.colorDepth,
pixelDepth: window.screen.pixelDepth,
devicePixelRatio: window.devicePixelRatio || 1,
};
}如有错误,请提交issue :::