Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 无法读取属性';setData';未定义-反应触摸事件_Reactjs_Redux_Touch Event - Fatal编程技术网

Reactjs 无法读取属性';setData';未定义-反应触摸事件

Reactjs 无法读取属性';setData';未定义-反应触摸事件,reactjs,redux,touch-event,Reactjs,Redux,Touch Event,我的触摸功能定义是 onDragStart(ev,id) { console.log('dragstart: ',id) ev.dataTransfer.setData("id",id) } onTouchStart(ev,id) { console.log('touchstart: ',id) ev.dataTransfer.setData("id",id) } 在这里,控制台正确给出了touchstart:9824357,但下一行给出了无法读取未定义的属性“

我的触摸功能定义是

onDragStart(ev,id) {
    console.log('dragstart: ',id)
    ev.dataTransfer.setData("id",id)
}
onTouchStart(ev,id) {
    console.log('touchstart: ',id)
    ev.dataTransfer.setData("id",id)
}
在这里,控制台正确给出了
touchstart:9824357
,但下一行给出了
无法读取未定义的属性“setData”。此代码适用于onDragStart

我的部门是

<div 
    onDragStart={(e)=>this.onDragStart(e, id)}  
    onTouchStart={(e)=>this.onTouchStart(e, id)}
    draggable                    
    className="draggable">                    
</div>
this.onDragStart(e,id)}
onTouchStart={(e)=>this.onTouchStart(e,id)}
拖拉的
className=“draggable”>

我怎样才能解决这个问题?我是否应该为触摸事件添加或声明更多内容?

dom事件没有
数据传输属性。这不是一个拖放事件。要解决此问题,请删除行
ev.dataTransfer.setData(“id”,id)
,因为触摸事件没有发生。

给我们完整的工作片段我添加了onDragStart函数,它是拖动事件的工作片段添加完整的源代码,因为我可能有其他错误。你在哪里可以建议使用函数或属性来代替数据传输?不,我不能。我不知道您使用此代码的目标是什么。根据您告诉我们的,我只能告诉您代码引发异常的原因。我的目标是在我的drop事件中获取值,即
let id=ev.dataTransfer.getData(“id”)如果您正在使用redux,则发送一个操作。为什么你认为这是一个好主意monkeypatch dom事件?