当前位置: 代码迷 >> 综合 >> uniapp 缓存多个数据
  详细解决方案

uniapp 缓存多个数据

热度:46   发布时间:2023-09-19 07:49:28.0

获取

			uni.getStorage({key:'username',}).then(res => {// 如果返回数组为两位就是正确if(res.length==2){this.username = res[1].data;}return uni.getStorage({key:'password',})}).then(res => {if(res.length==2){this.password = res[1].data;}return uni.getStorage({key:'ipAddress',})}).then(res => {if(res.length==2){this.ipAddress = res[1].data;}})

  添加

							uni.setStorage({key:'token',data: res.access_token,}).then(res => {// console.log("保存token");return uni.setStorage({key:'username',data: this.username,})}).then(res => {// console.log("保存name");return uni.setStorage({key:'password',data: this.password,})}).then(res => {// console.log("保存password");return uni.setStorage({key:'ipAddress',data: this.ipAddress,})}).then(res => {// console.log("保存ipAddress");uni.switchTab({url: './home'})})