cordova 強制豎屏


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" />

.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM