简体   繁体   English

忽略移动设备上的设备方向

[英]Ignore device orientation on mobile

I have a Vue js component that triggers a method every time the orientation of the device changes to landscape.我有一个 Vue js 组件,每次设备的方向更改为横向时都会触发一个方法。 I have used window.addEventListener("orientationchange", functionName, false);我用过window.addEventListener("orientationchange", functionName, false); to trigger the method.来触发方法。

This works perfectly fine on mobile when the device orientation is set to auto-rotate, but it doesn't when the orientation is set to portrait.当设备方向设置为自动旋转时,这在移动设备上工作得很好,但当方向设置为纵向时则不然。

Is there any way to overwrite the portrait mode and detect when the device is rotating in order to trigger the method?有什么方法可以覆盖纵向模式并检测设备何时旋转以触发该方法?

Setting the app to fullscreen mode and then calling window.screen.orientation.lock("any");将应用程序设置为全屏模式,然后调用window.screen.orientation.lock("any"); did the trick.成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM