随身笔记
随身笔记

页面缩放触发js事件

https://sdeno.com/wp-content/uploads/2023/11/suofng.png
<script>

    function devicepix(){
        let currentPixelRatio = window.devicePixelRatio;

        if (currentPixelRatio !== lastPixelRatio) {
            console.log('页面缩放变化了');
        }

        lastPixelRatio = currentPixelRatio;
        console.log(lastPixelRatio)
    }


    let lastPixelRatio = window.devicePixelRatio;
    window.addEventListener('resize', devicepix);

    devicepix()
</script>

 

随身笔记

页面缩放触发js事件
<script> function devicepix(){ let currentPixelRatio = window.devicePixelRatio; if (currentPixelRatio !== lastPixelRatio) { cons…
扫描二维码继续阅读
2023-11-22