记录:
// 获取屏幕缩放比例
getRatio() {
var ratio = 0
var screen = window.screen
var navi = navigator.userAgent.toLowerCase()
if (window.devicePixelRatio !== undefined) {
ratio = window.devicePixelRatio
} else if (~navi.indexOf('msie')) {
if (screen.deviceXDPI && screen.logicalXDPI) {
ratio = screen.deviceXDPI / screen.logicalXDPI
}
} else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
ratio = window.outerWidth / window.innerWidth
}
if (ratio) {
ratio = Math.round(ratio * 100)
}
return ratio
}
屏幕分辨率的高:window.screen.height*getRatio()/100 //乘以缩放比例为真实的像素
屏幕分辨率的宽:window.screen.width*getRatio()/100 //乘以缩放比例为真实的像素
屏幕可用工作区高度:window.screen.availHeight;
屏幕可用工作区宽度:window.screen.availWidth;