"vue": "^2.5.2",
"axios": "^0.19.0",
"vue-axios": "^2.1.4",
"vue-router": "^3.0.1"
//对象
const infoobj = { name: 'hou', age: 24, id: '001' };
//字符串
const mystr="haha";
localStorage.setItem('min', JSON.stringify(infoobj));
localStorage.setItem('hang', mystr);
var data1 = JSON.parse(localStorage.getItem('min'));
var data2 = localStorage.getItem('hang');
//删除某个
localStorage.removeItem('min');
//删除所有
localStorage.clear();
Storage 发生变化(增加、更新、删除)时的 触发,同一个页面发生的改变不会触发,只会监听同一域名下其他页面改变 Storage
window.addEventListener('storage', function (e) {
console.log('key', e.key); console.log('oldValue', e.oldValue);
console.log('newValue', e.newValue); console.log('url', e.url);
})
存储登录后的信息, 如TOKEN, 在成功登录后, 将TOKEN存到localStorage,每次向后端发请求,带上localStorage的数据