[英]Ionic Storage is not working on Android device
I'm new to the Ionic Framework, and I'm doing an app that preserves the user login so it can show a different page when user is logged.我是 Ionic 框架的新手,我正在开发一个保留用户登录信息的应用程序,以便在用户登录时显示不同的页面。 And for doing this, I'm saving the user ID into the local storage.
为此,我将用户 ID 保存到本地存储中。 This works fine when I do
ionic serve
and testing the code on browser, but it doesn't work on my Android device (so I run ionic cordova run android
).当我做
ionic serve
并在浏览器上测试代码时,这很好用,但它在我的 Android 设备上不起作用(所以我运行ionic cordova run android
)。 Why?为什么? I have set the Storage right by using
IonicStorageModule.forRoot()
in app.module.ts -> imports[...]
.我通过在
app.module.ts -> imports[...]
使用IonicStorageModule.forRoot()
设置了存储权限。 Here's my code and my Ionic specs:这是我的代码和我的 Ionic 规格:
I just figured out my problem and built a solution.我只是想出了我的问题并建立了一个解决方案。 On the very first access in my app
userLoggedID
is completely empty (it wasn't neither undefined
nor null
), so I attached a catch()
instruction and now the code works fine.在我的应用程序中第一次访问时
userLoggedID
完全为空(它既不是undefined
也不是null
),所以我附加了一个catch()
指令,现在代码工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.