本文整理汇总了TypeScript中@ionic-native/native-storage.NativeStorage.setItem方法的典型用法代码示例。如果您正苦于以下问题:TypeScript NativeStorage.setItem方法的具体用法?TypeScript NativeStorage.setItem怎么用?TypeScript NativeStorage.setItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ionic-native/native-storage.NativeStorage
的用法示例。
在下文中一共展示了NativeStorage.setItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
this.serverProvider.post(this.storageProvider.serverAddress+"/preventMultiLogin",body).then((res:any)=>{
console.log("res:"+JSON.stringify(res));
if(res.result=="success"){
// move into TabPage
if(res.userInfo.hasOwnProperty("shopList")){
this.storageProvider.shoplistSet(JSON.parse(res.userInfo.shopList));
}
//save this.storageProvider.id
this.storageProvider.userInfoSetFromServer(res.userInfo);
//save id information into storage
let id=this.navParams.get("id");
if(id!=undefined){
var encrypted:string=this.storageProvider.encryptValue('id',id);
this.nativeStorage.setItem('id',encodeURI(encrypted));
this.storageProvider.id=id;
}else{
//read id info and then save it into storageProvider
this.nativeStorage.getItem("id").then((value:string)=>{
this.storageProvider.id=this.storageProvider.decryptValue("id",decodeURI(value));
});
}
console.log("move into TbasPage");
this.app.getRootNav().setRoot(TabsPage);
}else{
console.log("move into LoginPage");
// move into loginPage
this.storageProvider.reset();
this.app.getRootNav().setRoot(LoginPage);
}
});
示例2: if
this.serverSecretSubmit().then((res:any)=>{
console.log("secretSubmit "+JSON.stringify(res));
if(res.result=="success"){
if(this.id.startsWith("facebook_")){
var encrypted:string=this.storageProvider.encryptValue('id','facebook');
this.nativeStorage.setItem('id',encodeURI(encrypted));
}else if(this.id.startsWith("kakao_")){
var encrypted:string=this.storageProvider.encryptValue('id','kakao');
this.nativeStorage.setItem('id',encodeURI(encrypted));
}
this.shoplistHandler(res.shopUserInfo);
}else if(res.result=='invalidId'){
console.log("You have no right to access this app");
//this.storageProvider.errorReasonSet('접근권한이 없습니다.');
this.navController.setRoot(ErrorPage);
}else{
console.log("invalid result comes from server-"+JSON.stringify(res));
//this.storageProvider.errorReasonSet('서버로 부터 알수 없는 응답을 받았습니다.');
this.navController.setRoot(ErrorPage);
}
},(err)=>{
示例3: Promise
return new Promise((resolve,reject)=>{
let headers = new Headers();
headers.append('Content-Type', 'application/json');
console.log("saveOrder:"+body);
this.post(encodeURI(this.storageProvider.serverAddress+"/saveOrder"),body).then((res:any)=>{
console.log("res:"+JSON.stringify(res));
console.log("saveOrder-res.result:"+res.result);
if(res.result=="success"){
//resolve(res.orders);
resolve(res);
}else{
reject(res.error);
}
},(err)=>{
reject(err);
});
this.nativeStorage.setItem("orderDoneFlag","true");
});
示例4:
this.nativeStorage.getItem(username).then((user)=>{
user.favorites=this.favorites;
this.nativeStorage.setItem(user.username,user).then(()=>{
console.log("deleted favorite")
},error=>{console.error("error en set item")})
})