可以使用 onPageShow onPageHide来设置页面级别的横屏onPageShow(): void { // window.getLastWindow(getContext(this), (err, win) => { // win.setPreferredOrientation(window.Orientation.LANDSCAPE_INVERTED) // }) } onPageHide(): void { window.getLastWindow(getContext(this), (err, win) => { win.setPreferredOrientation(window.Orientation.PORTRAIT) })或者在上一个界面跳转第二个界面的时候调用横屏,demo以下Button('界面跳转') .onClick(()=>{ window.getLastWindow(getContext(this), (err, win) => { win.setPreferredOrientation(window.Orientation.LANDSCAPE_INVERTED) }) router.pushUrl({ url:"pages/Index2" }) })setPreferredOrientation的使用请详细参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-refere...
可以使用 onPageShow onPageHide来设置页面级别的横屏
或者在上一个界面跳转第二个界面的时候调用横屏,demo以下
setPreferredOrientation的使用请详细参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-refere...