开发者问题收集

addEventListener 事件未捕获 TypeError:e.stopPropogation 不是一个函数

2019-12-11
2098

向按钮添加事件监听器会抛出

Uncaught TypeError: e.stopPropogation is not a function

document.getElementById(`test`).addEventListener('click', (e) => this.handleOpen(e), false)

处理程序

handleOpen = e => {
  e.stopPropagation()
  console.log(e)
  console.log(e.stopPropagation) //undefined
}
2个回答
Rohan Bhangui
2019-12-11

拼写错误。应为 e.stopPropagation

adam tropp
2019-12-11