orentation的默认值是default

可使用的值有:default, landscape (横屏), portait (竖屏)

orentation可以将设备锁定方向,不受设备旋转影响。


方案一:

1、添加插件

cordova plugin add net.yoik.cordova.plugins.screenorientation

2、添加屏幕配置 (Config.xml文件里面添加)

<preference name="orientation" value="portrait" />

3、在Index.html 界面 添加JS 屏幕监听事件

<script> 
  document.addEventListener("deviceready", onDeviceReady, false); 
  function onDeviceReady(){
    var so = cordova.plugins.screenorientation; 
    so.setOrientation(so.Orientation.LANDSCAPE); 
  } 
</script>

方案二:

1、添加插件

cordova plugin add cordova-plugin-screen-orientation

2、添加屏幕配置 (Config.xml文件里面添加)

<preference name="orientation" value="portrait" />

.

相关文章:

  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2021-08-30
  • 2021-11-25
猜你喜欢
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-03-07
相关资源
相似解决方案