本文整理匯總了TypeScript中ionic-angular.Storage.setJson方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Storage.setJson方法的具體用法?TypeScript Storage.setJson怎麽用?TypeScript Storage.setJson使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ionic-angular.Storage
的用法示例。
在下文中一共展示了Storage.setJson方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
AKStorage.getThirdParties().then(value => {
let newValue;
if (!value || value.length <= 0 || value.find((tp) => tp.name === name)) {
newValue = [data];
} else {
const position = value.findIndex((tp) => tp.name === name);
newValue = Object.assign([], value);
newValue.splice(position, 1, data);
}
local.setJson(AKStorage.THIRD_PARTY, newValue);
})
示例2: upsertThirdParty
},
// 插入或修改第三方登錄記錄
upsertThirdParty(data) {
const {name} = data;
if (data) {
AKStorage.getThirdParties().then(value => {
let newValue;
if (!value || value.length <= 0 || value.find((tp) => tp.name === name)) {
newValue = [data];
} else {
const position = value.findIndex((tp) => tp.name === name);
newValue = Object.assign([], value);
newValue.splice(position, 1, data);
}
local.setJson(AKStorage.THIRD_PARTY, newValue);
})
}
},
load(key) {
if (store[key]) return Promise.resolve(store[key]);
return local.getJson(key).then(value => store[key] = value);
},
save(key, value) {
store[key] = value;
if (value) local.setJson(key, value);
else local.remove(key);
},
};
示例3:
(response) => {
this.storage.setJson("user", response)
this.nav.setRoot(TabsPage);
},
示例4: setValue
setValue(key: string, value: any): Promise<any> {
return this.storage.setJson(key, value)
.then((value) => { return JSON.parse(value) })
.catch((error) => { return error; });
}
示例5:
this.user.login(this.username, this.password).then((response) => {
this.storage.setJson("user", response);
this.nav.push(TabsPage);
}).catch((object: { title: string, subTitle: string, buttons: Array<any> }) => {
示例6: save
async save(v?: T): Promise<void> {
v = v || await this._cache;
logger.debug(() => `Saving ${this.key}: ${JSON.stringify(v)}`);
await this.storage.setJson(this.key, v);
}