- father::常见的前端业务需求
- use::
storage事件
-
事件触发条件:
storage
事件只会在其他窗口或标签页修改localStorage
时触发。在同一窗口中对localStorage
的修改不会触发此事件。 -
事件处理: 可以通过监听
window
对象的storage
事件来处理:window.addEventListener('storage', function(event) { if (event.key === 'yourKey') { console.log('localStorage has changed:', event.newValue); } });
-