问题
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. And for doing this, I'm saving the user ID into the local storage.
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
). Why? I have set the Storage right by using IonicStorageModule.forRoot()
in app.module.ts -> imports[...]
. Here's my code and my Ionic specs:
回答1:
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.
LOG:
来源:https://stackoverflow.com/questions/54028978/ionic-storage-is-not-working-on-android-device