Víctor Hugo Tirado Asked: 2020-09-28 22:27:41 +0800 CST 2020-09-28 22:27:41 +0800 CST 2020-09-28 22:27:41 +0800 CST ionic 3中的锁定屏幕方向 772 提前感谢您的帮助,我正在几个地方寻找信息,但我找不到有关它的解决方案。我正在使用 ionic 3 进行应用程序,但由于元素的排列,我需要设备的方向始终是水平的。有没有办法水平锁定它?非常感谢你的一切。 ionic3 2 Answers Voted Best Answer sanzante 2020-09-28T23:17:14+08:002020-09-28T23:17:14+08:00 您需要 Cordova Screen Orientation 插件和 Ionic Native。 ionic cordova plugin add cordova-plugin-screen-orientation npm install --save @ionic-native/screen-orientation 你会像这样使用它: import { ScreenOrientation } from '@ionic-native/screen-orientation'; constructor(private screenOrientation: ScreenOrientation) { } ... // get current console.log(this.screenOrientation.type); // logs the current orientation, example: 'landscape' // set to landscape this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE); // Act on orientation change. this.screenOrientation.onChange().subscribe( () => { console.log("Orientation Changed"); } ); 您在 Cordova Screen Orientation插件中有详细信息。 asedio 2020-02-12T04:35:30+08:002020-02-12T04:35:30+08:00 在 config.xml 中,如果您希望它是水平的,则必须添加: < preference name="orientation" value="landscape" /> 如果你想让它垂直: < preference name="Orientation" value="portrait" />
您需要 Cordova Screen Orientation 插件和 Ionic Native。
你会像这样使用它:
您在 Cordova Screen Orientation插件中有详细信息。
在 config.xml 中,如果您希望它是水平的,则必须添加:
如果你想让它垂直: