The client module storing operation

/ ** 
 * The client stores the operating module 
 * / 
Export default { 
  / ** 
   * Save the client stores a string 
   * / 
  setStr: function (Key, value) { 
    (! Key) IF return 
    typeof value === ' Object '&& (the JSON.stringify value = (value)) 
    window.sessionStorage.setItem (Key, value) 
  }, 
  / ** 
   * original client to save storage type 
   * / 
  SET: function (Key, value) { 
    IF ( ! Key) return 
    value = the JSON.stringify (value) 
    window.sessionStorage.setItem (Key, value) 
  }, 
  / ** 
   * to obtain the original data type 
   * / 
  GET: function (Key) { 
    ! IF (Key) return null
    the JSON.parse return (window.sessionStorage.getItem (Key)) 
    IF (Key!) return
  } 
  / ** 
   * Get the type of the data string 
   * / 
  getStr: function (Key) { 
    IF return null (Key!) 
    Return window.sessionStorage.getItem (Key) 
  }, 
  Remove: function (Key) { 
    return window.sessionStorage. the removeItem (Key) 
  }, 
  / ** 
   * Get string type data from the LocalStorage 
   * / 
  getLocalStr: function (Key) { 
    IF (Key!) return null 
    return window.localStorage.getItem (Key) 
  }, 
  / ** 
   * character saving string to form the LocalStorage 
   * / 
  setLocalStr: function (Key, value) { 
    typeof value === 'Object' && (the JSON.stringify value = (value))
    window.localStorage.setItem(key, value)
  },
  removeLocal: function (key) {
    return window.localStorage.removeItem(key)
  }
}

 

Guess you like

Origin www.cnblogs.com/ympjsc/p/12304387.html
Recommended