2017-07-04 82 views

回答

2
使用

我们Cordova Screen Orientation Plugin固定。

在下面的代码app.js

document.addEventListener("deviceready", function() { 
    if (window.innerHeight <= 736 || window.innerWidth <= 736) { 
     screen.orientation.lock('portrait'); 
    } else { 
     screen.orientation.unlock('portrait'); 
    } 
}); 

window.addEventListener("orientationchange", function() { 
    if (window.innerHeight <= 736 || window.innerWidth <= 736) { 
     screen.orientation.lock('portrait'); 
    } else { 
     screen.orientation.unlock('portrait'); 
    } 
}); 
0

如果你想允许potrait模式,再加入 -

<platform name="android"> 
    <preference name="Orientation" value="portrait" /> 
    <allow-intent href="market:*" /> 
</platform> 

<widget>标签在​​3210在项目文件夹。

就此Cordova Device插件而言,您可能未找到Tablet or Mobile version插件。

可以得到以下properties -

  • device.cordova //版本科尔多瓦的设备上运行。
  • device.model //设备的模型或产品
  • device.platform //设备的操作系统名称
  • device.uuid
  • device.version
  • device.manufacturer //设备的制造商的名称。
  • device.isVirtual //设备是虚拟的(模拟)或真实
  • device.serial
0

使用,

document.addEventListener("deviceready", function() { 
if (window.innerHeight <= 736 || window.innerWidth <= 736) { 
    screen.orientation.lock('portrait'); 
} else { 
    screen.orientation.unlock('portrait'); 
} 
}); 
相关问题