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

2020 前端面试题 —— DOM相关 #49

Open
fengmiaosen opened this issue May 6, 2020 · 0 comments
Open

2020 前端面试题 —— DOM相关 #49

fengmiaosen opened this issue May 6, 2020 · 0 comments

Comments

@fengmiaosen
Copy link
Owner

  1. 事件委托

    事件委托就是利用事件冒泡,只指定一个事件处理程序,就可以管理某一类型的所有事件.
    在绑定大量事件的时候往往选择事件委托。

    • 优点:

      • 节省内存占用,减少事件注册
      • 新增子对象时无需再次对其绑定事件,适合动态添加元素
    • 局限性

      • focus、blur 之类的事件本身没有事件冒泡机制,所以无法委托
      • mousemove、mouseout 这样的事件,虽然有事件冒泡,但是只能不断通过位置去计算定位,对性能消耗高,不适合事件委托
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant