role.js 789 B

1234567891011121314151617181920212223242526
  1. export function saveObjArr(name, data) { // localStorage 存储数组对象的方法
  2. localStorage.setItem(name, JSON.stringify(data))
  3. }
  4. export function getObjArr(name) { // localStorage 获取数组对象的方法
  5. return JSON.parse(localStorage.getItem(name));
  6. }
  7. export function removeObjArr(name) { // localStorage 获取数组对象的方法
  8. localStorage.removeItem(name)
  9. }
  10. //session
  11. export function saveSession(name, data) { // localStorage 存储数组对象的方法
  12. sessionStorage.setItem(name, JSON.stringify(data))
  13. }
  14. export function getSession(name) {
  15. //localStorage 获取数组对象的方法
  16. return JSON.parse(sessionStorage.getItem(name));
  17. }
  18. export function removeSession(name) { //localStorage 获取数组对象的方法
  19. sessionStorage.removeItem(name)
  20. }