我正在用 ionic 做我的第一步,我問我是否可以在 ionic 應用程式中使用它:
import {LocalStorageService} from 'ngx-webstorage';
或者有沒有更好的方法在認證后存盤用戶的登錄資料?
uj5u.com熱心網友回復:
Ionic 已經提供了存盤抽象,您可以在不匯入外部包的情況下使用它。
import { Storage } from '@ionic/storage';
private store: Storage;
constructor(private storage: Storage) { }
async init() {
this.store = await this.storage.create();
}
save(userData: any) {
this.store.set('user', userData);
}
見https://github.com/ionic-team/ionic-storage詳細資訊
uj5u.com熱心網友回復:
在說登錄資料時,我想您指的是用戶的令牌?因為您不應該在本地存盤任何用戶憑據。
除此之外,還有關于這個主題的各種主題,即 localStorage 與 cookies,請參閱此內容或更新的內容。
但是要回答您的問題,沒有理由說明為什么您不應該使用該軟體包,看看它如何提供各種生活質量改進和有用的處理程式。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/367282.html
