plus.screen.lockOrientation('default'); // 默认横竖屏切换
plus.screen.lockOrientation('portrait-primary');// 竖屏展示
plus.screen.lockOrientation('landscape-primary'); // 强制横屏
让某个界面只能横屏或者竖屏展示,其他界面不影响
home界面~可以切横竖屏
onLoad() {
// #ifdef APP-PLUS
plus.screen.lockOrientation('default');//页面加载允许横竖屏展示
// #endif
},
me界面~只允许竖屏
//生命周期~页面显示时切换为横屏配置
onShow() {
// #ifdef APP-PLUS
uni.showLoading({
title: "加载中..."
})
setTimeout(() => {
plus.screen.unlockOrientation();
plus.screen.lockOrientation('portrait-primary');
uni.hideLoading();
}, 200)
//#endif
},
//生命周期~页面卸载时取消
onUnload() {
// #ifdef APP-PLUS
plus.screen.lockOrientation('default');
// #endif
},