Leetcode icon indicating copy to clipboard operation
Leetcode copied to clipboard

45. 什么是存储事件及其事件处理程序

Open webVueBlog opened this issue 3 years ago • 0 comments

StorageEvent 是在另一个文档的上下文中更改存储区域时触发的事件。而 onstorage 属性是用于处理存储事件的 EventHandler。语法如下

window.onstorage = functionRef;

让我们以 onstorage 事件处理程序的用法为例,它记录存储键及其值

window.onstorage = function (e) {
  console.log(
    "The " +
      e.key +
      " key has been changed from " +
      e.oldValue +
      " to " +
      e.newValue +
      "."
  );
};

webVueBlog avatar Jun 09 '22 02:06 webVueBlog