Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
onresize committed May 23, 2024
1 parent e19f434 commit 8e1ceb1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/.vuepress/config/silder.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default [
'/技术总结/踩坑总结/worker',
'/技术总结/踩坑总结/浏览器跨页面,跨窗口通信',
'/技术总结/踩坑总结/跨域相关',
'/技术总结/踩坑总结/如何监听localStorage中的值的变化',
'/技术总结/踩坑总结/web端扫码的几种方案',
'/技术总结/踩坑总结/vite.config.js常用配置',
'/技术总结/踩坑总结/vue.config.js常用配置',
Expand Down
2 changes: 2 additions & 0 deletions docs/技术总结/踩坑总结/docker前端篇.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ description: docker前端篇
# docker前端篇
> 本文作者:[onresize](https://github.com/onresize)
[✨Docker入门教程(非常详细)从零基础入门到精通✨](https://www.webfunny.com/blog/post/235)
<br />
[docker中文指南](https://yeasy.gitbook.io/docker_practice)
<br />
[docker入门实践](https://docker.easydoc.net/)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: 如何监听localStorage中的值的变化
lang: zh-CN
feed:
enable: true
description: 如何监听localStorage中的值的变化
---

# 如何监听localStorage中的值的变化

> 本文作者:[onresize](https://github.com/onresize)
```js
function dispatchEventStorage() {
const signSetItem = localStorage.setItem
localStorage.setItem = function (ley, val) {
let setEvent = new Event('setItemEvent')
setEvent.key = key
setEvent.newVal = val
window.dispatchEvent(setEvent)
signSetItem.apply(this, arguments)
}
}
dispatchEventStorage()

window.addEventListener('setItemEvent', (e) => {
// TODO...
})
```

0 comments on commit 8e1ceb1

Please sign in to comment.