js 动态判断移动端横竖屏

var eventPassthrough = '';
    window.addEventListener("orientationchange", function() {
        if (window.orientation === 0) {
            console.log('竖屏');
            eventPassthrough = 'horizontal';
        } else if (window.orientation === 90) {
            console.log('横屏');
            eventPassthrough = 'portrait';
        }
        console.log(window.orientation, 'orientation');
    
    }, false);

本文参考至: https://www.cnblogs.com/xianyulaodi/p/5533185.html

原文地址:https://www.cnblogs.com/ljy-/p/13275310.html