在onWindowStageCreate 设置跟随传感器自动旋转,参考demolet orientation = window.Orientation.AUTO_ROTATION; let windowClasss : window.Window = windowStage.getMainWindowSync() windowClasss.setPreferredOrientation(orientation, (err: BusinessError) => { const errCode: number = err.code; if (errCode) { console.error(`Failed to set window orientation. Cause code: ${err.code}, message: ${err.message}`); return; } console.info('Succeeded in setting window orientation.'); });参考文档https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-window-V5\#setpreferredorientation9https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-window-V5\#orientation9
在onWindowStageCreate 设置跟随传感器自动旋转,
参考demo
参考文档
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-window-V5\#setpreferredorientation9
https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-window-V5\#orientation9