ionic2 判断是否是第一次登陆应用是否实现启动页的显示

1。实现对storage的引入和使用

http://ionicframework.com/docs/storage/


2。在app.component.ts里面引入这个storage   还有其他的引入文件我没有全部写完

import { Storage } from '@ionic/storage';

@ Component({
templateUrl: 'app.html',
})
export class MyApp {
rootPage: any = WelcomePage;
// public firstIn=false;

constructor( platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private storage: Storage) {

///这里如果打开直接就跳到tab页面了
//这里不能直接用firstIn他用了过后表示直接就有了。。。
this. storage. get( 'firstTo'). then(( result) => {
if( result){
alert( "是否是第一次进入程序"+ result) //不是就直接
this. rootPage = LoginPage;
}
else{
console. log( "设置")
this. storage. set( 'firstTo', true);
console. log( this. storage. get( 'firstTo'))
this. rootPage = WelcomePage;
}
})

platform. ready(). then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar. styleDefault();
splashScreen. hide();
});
}


}


之前在http://blog.csdn.net/k_men/article/details/53164613   看到使用的是firstIn但是无论怎么获取他都是true在没设置val值的时候也是,所以我这里使用了firstTo最后成功,所以将步骤写下来,也是为找了那么久做总结吧

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值