t***@163.com
t***@163.com
  • 发布:2019-02-11 12:30
  • 更新:2020-04-22 11:10
  • 阅读:3862

uniapp 能否检测横竖屏切换触发回调函数

分类:uni-app

uniapp 能否检测横竖屏切换触发回调函数
想在每次横竖屏切换后。设置不同的class
求检测办法!

2019-02-11 12:30 负责人:无 分享
已邀请:

最佳回复

LCZ

LCZ

        onResize() {  
            uni.getSystemInfo({  
                success: function(res) {  
                    console.log(res.windowWidth);  
                    console.log(res.windowHeight);  
                    if (res.windowWidth > res.windowHeight) {  
                        console.log('横屏');  
                    } else {  
                        console.log('竖屏');  
                    }  
                }  
            });  
        },

https://uniapp.dcloud.io/api/system/deviceMotion

  • 2***@qq.com

    这里有个tip要注意一下, success: function(res) { }后面如果使用到this。要注意this的指向

    2022-02-15 19:15

爱吃鱼的靖哥哥

爱吃鱼的靖哥哥 - 行走在全栈路上的码农

video全屏后这个接口根本就不会触发

该问题目前已经被锁定, 无法添加新回复