UNPKG

ptool

Version:

vue项目开发通用工具类封装

39 lines (38 loc) 904 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * @FileName sStorage.ts * @Author Mad Dragon <395548460@qq.com> * @Version V 0.0.1 * @Date 2021/4/13 11:48 * @Title sessionStorage操作 * @Desc **/ const setItem = (key, content) => { if (!key && typeof window === 'undefined') return; let contentTxt = content; if (typeof content !== 'string') { contentTxt = JSON.stringify(content); } sessionStorage.setItem(key, contentTxt); }; const getItem = (key) => { if (!key && typeof window === 'undefined') return; return sessionStorage.getItem(key) || ''; }; const removeItem = (key) => { if (!key && typeof window === 'undefined') return; sessionStorage.removeItem(key); }; const clear = () => { sessionStorage.clear(); }; exports.default = { setItem, getItem, removeItem, clear };