"onDrag"事件未在react.js中触发

Ama*_*mes 12 javascript reactjs

<div className="kat-project-user-timeline-drag-indicator-wrapper-bottom"
     onDrag={(event) => {this.dragTask(event)}}>
</div>

dragTask(event) {
  console.log("logic goes here")
}
Run Code Online (Sandbox Code Playgroud)

第一次没有调用该函数.但从第二次起,它工作正常.我尝试使用,event.preventDefault(),但它仍然无法正常工作.

Hat*_*ber 20

尝试添加draggable="true",看看是否有效:

<div draggable="true" className="kat-project-user-timeline-drag-indicator-wrapper-bottom"
 onDrag={(event) => {this.dragTask(event)}}>
</div>

dragTask(event) {
  console.log("logic goes here")
}
Run Code Online (Sandbox Code Playgroud)

  • 对不起,如果那是错误的,我的意思不是错误的! (2认同)