/** * 向localStorage中设置数据 * @param key 字符串 * @param value 数组 */ function SetDataIntoLocalStorage(key, value) { localStorage.setItem(key, JSON.stringify(value)); } /** * 从localStorage中获取数据 * @param key 字符串 */ function GetDataFromLocalStorage(key) { return JSON.parse(localStorage.getItem(key)); } /** * 从localStorage中移除数据 * @param keysArr 数组 */ function RemoveDataFromLocalStorage(keysArr) { if (keysArr.length > 0) { for(var i = 0, len = keysArr.length; i < len; i++) { localStorage.removeItem(keysArr[i]); } } }