parent
6abe45c218
commit
91a2ef8770
@ -0,0 +1,20 @@
|
|||||||
|
let ratio = 0,
|
||||||
|
screen = window.screen,
|
||||||
|
ua = navigator.userAgent.toLowerCase()
|
||||||
|
if (window.devicePixelRatio !== undefined) {
|
||||||
|
ratio = window.devicePixelRatio
|
||||||
|
} else if (~ua.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)
|
||||||
|
}
|
||||||
|
// ratio 就是获取到的百分比
|
||||||
|
// console.log(ratio);
|
||||||
|
|
||||||
|
export default ratio
|
Loading…
Reference in new issue