userUtil.js 464 B

12345678910111213141516
  1. class UserUtils {
  2. constructor() {
  3. this.LOCAL_USER_INFO_KEY = 'USER_INFO';
  4. }
  5. setVal(val) {
  6. window.sessionStorage.setItem(this.LOCAL_USER_INFO_KEY, JSON.stringify(val))
  7. }
  8. getVal() {
  9. return window.sessionStorage.getItem(this.LOCAL_USER_INFO_KEY) ? JSON.parse(window.sessionStorage.getItem(this.LOCAL_USER_INFO_KEY)) : null
  10. }
  11. removeVal() {
  12. window.sessionStorage.removeItem(this.LOCAL_USER_INFO_KEY)
  13. }
  14. }
  15. export default new UserUtils();