dispatchEventStroage (){
const signSetItem = localStorage.setItem
localStorage.setItem = function (key, val) {
let setEvent = new Event('setItemEvent')
setEvent.key = key
setEvent.newValue = val
window.dispatchEvent(setEvent)
signSetItem.apply(this, arguments)
}
}
window.addEventListener('setItemEvent', function (e) {
if(e.key && e.newValue && e.key == "xxx"){
alert("进入");
}
})
网友评论