zoukankan      html  css  js  c++  java
  • localstorage累加存取数组

    /*
     * 累加存值
     */			
    var yongyaofanan = {
    	getItem:function(){
    		return JSON.parse(window.localStorage.getItem('yongyaofanan'))||{};//取值
    	},
    	setItem:function(item){
    		window.localStorage.setItem('yongyaofanan',JSON.stringify(item));//存值
    		ObjAll = item;
    	},
    	update:function(key,value){
    		var item = this.getItem();
    		item[key] = value;
    		this.setItem(item);
    	}
    }
    
    

    /*
    * 存值
    */
    yongyaofanan.update('numnit',items[0].text);

    /*
    * 累加存值
    */
    var alls = [];
    var jisons = JSON.parse(window.localStorage.getItem('yongyaofanan'));
    if(jisons != null){
      alls.push(jisons);
    };

    /*
    * 取值
    */
    var medications = JSON.parse(window.localStorage.getItem('alls'));

      

    ゛Toly★小饼干ゞ
  • 相关阅读:
    JZOJ.2117. 【2016-12-30普及组模拟】台风
    团队合作
    长沙游记
    统计
    html....
    OI之路
    三鑫普及组模拟赛
    牛顿迭代法
    台风
    gcd
  • 原文地址:https://www.cnblogs.com/rockyan/p/7531978.html
Copyright © 2011-2022 走看看