cookie_js
npm install cookie_js --save
储存
cookie.set(‘key‘, ‘value‘);
cookie.set(key1: ‘value1‘; key2: ‘value2‘);
获取
cookie.get(‘key‘);
cookie.get(‘key1‘, ‘key2‘);
清除
cookie.remove(‘key‘);
cookie.remove(‘key1‘, ‘key2‘);
cookie.remove([ ‘key1‘, ‘key2‘ ]);
HTML5本地存储
存储大小:5M,存储于客户端,而且只能存储字符串类型
sessionStorage(临时性,关闭浏览器即清除
存储
window.sessionStorage.setItem("key", "value");
获取
window.sessionStorage.getItem("key");
删除
window.sessionStorage.removeItem("key");
清空
sessionStorage.clear();
localStorage(长期性,手动删除
将sessionStorage换位localStorage即可