【发布时间】:2019-05-16 09:58:58
【问题描述】:
我需要帮助来解决这个问题。
在 home.ts 中,我检查用户之前是否使用 nativeStorage 登录过
home.ts
ionViewWillEnter() {
this.load();
}
load() {
this.chk = this.gettoken();
alert(this.chk)
if (this.chk == 'true')
{
//// code here
}
gettoken(): Promise<string> {
this.nativeStorage.getItem('isLoggedIn').then((value) => {
this.val = value;
});
return this.val;
};
}
在登录页面我使用这个保存到存储中:
this.nativeStorage.setItem('isLoggedIn','true');
第一次运行应用程序时,我得到了“未定义”,现在可以了。成功登录并关闭应用程序并再次运行后,我得到了“未定义”
我必须转到另一个页面并再次返回主页才能获取 storage 的值 (isLoggedIn) true
我把gettoken()改成这个:
async gettoken(){
return await this.storage.getItem('isLoggedIn');
}
但同样的问题
【问题讨论】:
标签: ionic3