app如何控制手机横屏

手机进入时直接是横屏,可以这样设置:

onShow() {
    
    
	//#ifdef APP-PLUS
		plus.screen.lockOrientation('landscape-primary');
	//#endif
},
onUnload() {
    
    
	//#ifdef APP-PLUS
		plus.screen.lockOrientation('portrait-primary');		
	//#endif
	
},

如页面是使用upx或rem等单位,可能会导致样式错乱。

解决方法:

  1. 可在进入横屏页面后,1300毫秒后再横屏
  2. 可不使用横屏操作,用样式旋转页面90度,达到横屏操作

猜你喜欢

转载自blog.csdn.net/pgzero/article/details/108379951