EN: Handle Storage (Keep fit for JSON, it can transfer format automatically).
ZH: 存储/获取数据到 sessionStorage/localStorage。
Usage:
setSessionStorage('test', '123');const ret1 = getSessionStorage('test');setLocalStorage('test', '123');const ret2 = getLocalStorage('test');console.log(ret1, ret2);// or package in usageconst projectName = 'mazey';function mSetLocalStorage (key, value) { return setLocalStorage(`${projectName}_${key}`, value);}function mGetLocalStorage (key) { return getLocalStorage(`${projectName}_${key}`);} Copy
setSessionStorage('test', '123');const ret1 = getSessionStorage('test');setLocalStorage('test', '123');const ret2 = getLocalStorage('test');console.log(ret1, ret2);// or package in usageconst projectName = 'mazey';function mSetLocalStorage (key, value) { return setLocalStorage(`${projectName}_${key}`, value);}function mGetLocalStorage (key) { return getLocalStorage(`${projectName}_${key}`);}
Output:
123 123 Copy
123 123
键
返回值
EN: Handle Storage (Keep fit for JSON, it can transfer format automatically).
ZH: 存储/获取数据到 sessionStorage/localStorage。
Usage:
Output: