2017-02-15 85 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