Skip to content

浏览器事件

浏览器事件模型

DOM 事件

  • DOM0 级事件
js
btn.onclick = function() {

}
  • react为合成事件
jsx
const onClickHandler = () => {

}
<div onClick={onClickHandler}></div>

v17 之前事件添加到 html 通过冒泡来进行事件捕获 v17 之后通过事件添加到 rootElement

  • DOM2 级事件 addEventListener removeEventListener
js
const fn = () => {}
btn.addEventListener

alt text

浏览器请求

  • ajax
  • fetch
  • axios

ajax

  • 手写 ajax
js
const ajax = (option) => {
    
}

xmlHttp.send()