限制Javascript中的方向更改

问题描述:

我正在构建混合移动应用程序。我只需要将方向限制为肖像模式即可。整个页面是一个单一的HTML。是否可以设置特定于div的纵向或横向?我想知道是否有可能处理这种情况。限制Javascript中的方向更改

您可以使用cordova-plugin-screen-orientation改变(或锁定/解锁)的应用程序编程方向:

// set to either landscape 
screen.lockOrientation('landscape'); 

// allow user rotate 
screen.unlockOrientation(); 

// access current orientation 
console.log('Orientation is ' + screen.orientation);