在module.json5添加属性"orientation": "auto_rotation"。如下所示:"abilities": [ { "name": "EntryAbility", "srcEntry": "./ets/entryability/EntryAbility.ets", "description": "$string:EntryAbility_desc", "icon": "$media:icon", "label": "$string:EntryAbility_label", "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background", "exported": true, "skills": [ { "entities": [ "entity.system.home" ], "actions": [ "action.system.home" ] } ], "orientation": "auto_rotation", // 随传感器旋转 } ]再打开手机自动旋转按钮即可。参考链接module.json5配置文件--abilities标签
如下所示:
参考链接
module.json5配置文件--abilities标签