本文整理汇总了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);
}