2017-02-15 101 views
2

我正在使用Ionic 2.尝试在本地存储中设置字符串。未设置本地存储

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

constructor(public storage: Storage) { 
} 


    createChat(chatItem: any): void { 
     this.storage.ready().then(() => { 
      var jsonString = JSON.stringify(chatItem); 
      this.storage.set('chat/' + chatItem.$key + '/', jsonString); 
     }); 
    } 

但是,当我看着Chrome的开发人员工具时,未设置该值。

任何帮助表示赞赏。

回答

3

根据Ionic docs

当在网络或作为进Web应用程序运行,存储将 尝试使用IndexedDB的,的WebSQL和localStorage的,按照这个顺序。

因此,它是正确的,它没有设置:你应该看看自己的Chrome IndexedDB而不是localStorage

+1

是的,它的存在。非常感谢你 – Richard