vue-simple
Version:
Use Vue in the simplest and easiest way, contain more than one of plugins and other to do that, i hope you will like it.
25 lines (24 loc) • 642 B
JavaScript
import _JSON$stringify from 'babel-runtime/core-js/json/stringify';
import STORAGE_TYPE from '../storageType';
/**
* sessionStorage 存储引擎
*/
export default {
type: STORAGE_TYPE.sessionStorage,
storage: sessionStorage || window.sessionStorage,
getItem: function getItem(key) {
var r = this.storage.getItem(key);
r = r ? JSON.parse(r) : r;
return r;
},
setItem: function setItem(key, value) {
value = _JSON$stringify(value);
this.storage.setItem(key, value);
},
removeItem: function removeItem(key) {
this.storage.removeItem(key);
},
clear: function clear() {
this.storage.clear();
}
};