Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
webVueBlog opened this issue Jun 9, 2022 · 0 comments
Open

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

webVueBlog opened this issue Jun 9, 2022 · 0 comments

Comments

@webVueBlog
Copy link
Owner

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 +
      "."
  );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant