主方案
APP.vue
亲测有效
onShow(() => {
// #ifdef APP-PLUS
// 设置应用横屏-根据重力感应确定方向
// "portrait-primary": 竖屏正方向;
// "portrait-secondary": 竖屏反方向,屏幕正方向按顺时针旋转180°;
// "landscape-primary": 横屏正方向,屏幕正方向按顺时针旋转90°;
// "landscape-secondary": 横屏方向,屏幕正方向按顺时针旋转270°;
// "portrait": 竖屏正方向或反方向,根据设备重力感应器自动调整;
// "landscape": 横屏正方向或反方向,根据设备重力感应器自动调整;
plus.screen.lockOrientation("portrait-primary")
// #endif
})
其他方案
1、pages.json
亲测和主方案效果一致,但支持参数较少
{
"globalStyle": {
// 旋转方向配置 仅支持 auto / portrait 竖屏<无正反向区分> / landscape 横屏<无正反向区分>
"pageOrientation": "portrait"
}
}
2、manifest.json
网上有这个方案,但使用默认基座未测试出效果-后续有时间再重新尝试
{
"app-plus":{
"distribute":{
"distribute": {
"orientation": ["portrait-primary"],
}
}
}
}