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

3

我在使用 Ionic Capacitor 启动屏时遇到了问题。我尝试使用官方文档,可以在此处找到:here。然而,文档中的示例似乎都无法正常运行。

这是我尝试的代码片段之一,位于 capacitor.config.json 文件中:

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

该应用程序的行为与以前完全相同,这可能是默认设置(启动画面显示3秒后加载应用程序)。

我还尝试过禁用自动隐藏等其他操作,但似乎没有任何代码实际上能够对其进行修改,应用程序仍然像以前一样运行。有什么想法吗?


这个回答解决了你的问题吗 https://dev59.com/WLnoa4cB1Zd3GeqPNUb5? - Stephane L
2个回答

0
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

注意: 如果您使用的是移动设备,请检查您的Wi-Fi是否与您的笔记本电脑相同。

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

-1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接