简体   繁体   English

在 Capacitor Ionic/Ionic React 中隐藏 Android 启动画面

[英]Hiding Android Splash screen in Capacitor Ionic/Ionic React

I'm having issues with the Ionic Capacitor Splashscreen.我在使用 Ionic Capacitor Splashscreen 时遇到问题。 I've tried to use the official documentation which can be found here .我尝试使用可以在 此处找到的官方文档。 However none of the examples in the documentation seem to run at all for me.但是,文档中的所有示例似乎都不适合我。

Just an example of what I've tried is this bit of code inside my capacitor.config.json:我尝试过的一个例子是我的 capacitor.config.json 中的这段代码:

"plugins": {
   "SplashScreen": {
     "launchShowDuration": 10000,
     "backgroundColor": "#ff00ff"
   }
 }

The app behaves exactly as it did prior, which is probably the default setting (splash showing for 3 seconds after which the app loads).该应用程序的行为与之前完全相同,这可能是默认设置(应用程序加载后显示 3 秒)。

I have also tried to disable autohide among other things, but none of the code seems to actually do much of anything, the app still runs as it did before.我还尝试过禁用自动隐藏等功能,但似乎没有任何代码实际上做了很多事情,应用程序仍然像以前一样运行。 Any ideas?有任何想法吗?

You can use Plugins.SplashScreen.hide method of Capacitor, I explained it in this answer: https://stackoverflow.com/a/62063934/6695569 .您可以使用电容器的Plugins.SplashScreen.hide方法,我在这个答案中解释了它: https://stackoverflow.com/a/62063934/6695569

import { SplashScreen } from '@capacitor/splash-screen';

// Hide the splash (you should do this on app launch)
await SplashScreen.hide();

// Show the splash for an indefinite amount of time:
await SplashScreen.show({
  autoHide: false
});

// Show the splash for two seconds and then automatically hide it:
await SplashScreen.show({
  showDuration: 2000,
  autoHide: true
});

https://capacitorjs.com/docs/apis/splash-screen?#example https://capacitorjs.com/docs/apis/splash-screen?#example

Note: if you use your device check your wifi if the same with your laptop注意:如果您使用您的设备,请检查您的 wifi 是否与您的笔记本电脑相同

 ´ionic capacitor run android -l --host=**192.168.X.XX**´ <br>
 ´ionic capacitor run android -l --host=**ADDRESS_IP**´

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM