我们如何禁用 Ionic 应用程序上的启动画面?我正在使用 Ionic 4、Capacitor 和 React。我试图在capacitor.config.json 上添加这个
{
"plugins": {
"SplashScreen": {
"launchShowDuration": 0
}
}
}
上面的代码根本不起作用。
我们如何禁用 Ionic 应用程序上的启动画面?我正在使用 Ionic 4、Capacitor 和 React。我试图在capacitor.config.json 上添加这个
{
"plugins": {
"SplashScreen": {
"launchShowDuration": 0
}
}
}
上面的代码根本不起作用。
您可以使用SplashScreen
插件隐藏启动画面:
import { Plugins } from '@capacitor/core';
const { SplashScreen } = Plugins;
function useSplashHide(){
useEffect(() => {
SplashScreen.hide();
}, []);
}
您可以像使用任何钩子一样使用它:
function MyComponent(props){
useSplashHide()
return <>....</>
}
文档在这里
电容版本 v2
https://capacitorjs.com/docs/v2/apis/splash-screen
import { Plugins } from '@capacitor/core';
const { SplashScreen } = Plugins;
1.调用隐藏()
// Hide the splash (you should do this on app launch)
SplashScreen.hide();<------------------------call hide function
2. 或将 showduration 设置为 0
// Show the splash for two seconds and then auto hide:
SplashScreen.show({
showDuration: 0,<------------------------set 0 duration to hide
autoHide: true,
});
版本 v3
您只需添加以下行 config.xml
<preference name="SplashScreenDelay" value="0"/>