如何在打开splash时设置localStorage值并对localstorage值进行测试以不再打开splash,我使用ionic 3并在config.xml上设置此配置:
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="true" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="0" />
<preference name="ShowSplashScreen" value="false" />
这是home.ts文件中的ionviewdidload函数:
ionViewDidLoad(){
if (localStorage.getItem('splash')=='0') {
this.tabBarElemen.style.display = 'none'
setTimeout(() => {
this.splash = false;
localStorage.setItem('splash','1');
this.tabBarElemen.style.display = 'flex';
}, 2000);
}
}
这是splashscreen的html代码:
<div id="custom-overlay" [style.display]="splash ? 'flex': 'none'">
<div class="flb">
<div class="Aligner-item Aligner-item--top"></div>
<img class="splash-screen-logo" src="img/logo.svg">
<div class="Aligner-item Aligner-item-bottom"></div>
</div>
</div>
请帮忙一些!感谢
答案 0 :(得分:2)
使用Ionic Native&#39; Splashscreen插件,您可以完全控制显示/隐藏您的闪屏。
示例:
import { SplashScreen } from '@ionic-native/splash-screen';
constructor(private splashScreen: SplashScreen) { }
this.splashScreen.show();
this.splashScreen.hide();
可在以下网址找到更多信息:Splashscreen docs