用于解决android启动页黑屏和ios白屏。
安装插件
cordova plugins add cordova-plugin-splashscreen
配置config.xml
<preference name="SplashScreenDelay" value="10000" />
<preference name="KeyboardDisplayRequiresUserAction" value="false" />
Quick Example
navigator.splashscreen.hide();
Full Example
$ionicPlatform.ready(function(){
if(navigator.splashscreen) {
if(ionic.Platform.isIOS()) {
setTimeout(function() {
navigator.splashscreen.hide();
}, 2000);
}else {
navigator.splashscreen.hide();
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>Splashscreen Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
navigator.splashscreen.hide();
}
</script>
</head>
<body>
<h1>Example</h1>
</body>
</html>
iOS Quirk
setTimeout(function() {
navigator.splashscreen.hide();
}, 2000);
参数资料
如果文章对你有帮助,欢迎点击上方按钮打赏作者