html1中:
本地存储的数字为随机数:
document.onclick = function(){
localStorage.num = Math.random();
}
html2中:
在一个浏览器中本地存储相同 检测storage的变化
// 只能检测到除了自身页面之外页面的storage变化
window.onstorage = function(eve){
// console.log(eve);
console.log(eve.key);
// console.log(eve.oldValue);
console.log(eve.newValue);
}
storage事件
最新推荐文章于 2022-09-26 09:51:38 发布