Open lengziyu opened 7 years ago
封装:
// 储存localStorage function setlocalStorage(storeName, storeData) { var storeStr = JSON.stringify(storeData); var storeArr = window.localStorage.setItem(storeName, storeStr); return storeArr; } //调用 setlocalStorage('userInfo', data);
// 获取localStorage function getlocalStorage(storeName) { var storeName = localStorage.getItem(storeName); var storeArr = JSON.parse(storeName) return storeArr; } getlocalStorage('userInfo');
删除:
localStorage.removeItem('userInfo');
封装:
删除: