zoukankan      html  css  js  c++  java
  • uniapp 缓存多个数据

    获取

                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.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'
                                    })
                                })					

      

  • 相关阅读:
    循环
    list和tuple
    Python字符串和编码注意点
    【转载】国内安卓推送的希望
    【转载】Android属性动画和视图动画的区别
    【转载】Android 属性动画详解
    【转载】 android 属性动画详解
    java8 新特性学习详细篇2
    java8 新特性详细篇
    JAVA8十大新特性
  • 原文地址:https://www.cnblogs.com/fhysy/p/15662633.html
Copyright © 2011-2022 走看看