【问题标题】:ionic 3 storage clear after re open the browser重新打开浏览器后,ionic 3 storage clear
【发布时间】:2019-07-05 20:35:54
【问题描述】:

我可以从存储中读取值,直到应用程序未关闭。 在我关闭浏览器并重新运行该应用程序后。我将从 storage.get 中获取 null 值

在教程页面中:

this.storage.set('hasSeenTutorial', 'true'); 

在component.ts中:

this.storage.get('hasSeenTutorial')
.then((hasSeenTutorial) => {
  debugger;
  if (hasSeenTutorial) {
    this.selectRootPage();
  } else {
    this.rootPage = 'TutorialPage';
  }
  this.platformReady()
});

【问题讨论】:

    标签: ionic-framework ionic3 storage


    【解决方案1】:

    对于 ionic-3,一个众所周知的事实是,本地存储会由浏览器/操作系统自行决定清除。如果您想要强制持久性并且不辜负浏览器/操作系统清除策略的摆布,请使用在 ionic documentation 中也推荐的插件 sqlite。

    【讨论】:

    • "cordova-sqlite-storage": "^3.2.1", and "@ionic/storage": "^2.2.0",这是我的 package.json
    • 很高兴知道这些东西
    猜你喜欢
    • 2021-09-29
    • 1970-01-01
    • 1970-01-01
    • 2019-04-12
    • 2013-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多