我具有输入类型作为文件。我正在为其定义onMouseDown函数。按顺序更改文件预览的位置。出现以下错误:TypeError:无法设置未定义属性'left'
<input
type="file"
className="file"
id="file-browser-input"
name="file-browser-input"
ref ={input=>this.fileInput=input}
onDragOver={(e)=>{
e.preventDefault();
e.stopPropagation();
}
}
onDrop={this.onFileLoad.bind(this)
onChange={this.onFileLoad.bind(this)}
onMouseDown={this.catchItem.bind(this)}
/>
catchItem(e) {
this.style.left = e.pageX - this.clientWidth / 2 + "px";
this.style.top = e.pageY - this.clientHeight / 2 + "px";
this.onmousemove = function(e) {
this.style.left = e.pageX - this.clientWidth / 2 + "px";
this.style.top = e.pageY - this.clientHeight / 2 + "px";
}
this.onmouseup = function() {
this.onmousemove = null; // onmouseup event [ redirect mousemove event signal to null instead of the
drag-able element]
}
}
似乎this.style
未定义