我正在研究reactjs。我收到了错误
Uncaught TypeError: Cannot read property 'left' of undefined
at HTMLDivElement.eval (DummyPlayer.js:184)
at HTMLDivElement.dispatch (dll.vendor.js:39569)
at HTMLDivElement.elemData.handle (dll.vendor.js:39381)
以下是我的代码
return (
<div>
<div className='video-player'>
<div className='video-player-inner'>
<video
className='video-js video-el vjs-big-play-centered vjs-default-skin'
id='video-el'
ref={node => this.video_el = node}>
<source src={this.props.video_file_selected_reducer.url} type="video/mp4"/>
</video>
</div>
</div>
<div id="custom-seekbar" onClick={this.customBarClicked}>
<span></span>
</div>
</div>
)
这是我的customBarClicked方法
customBarClicked(e){
var offset = $(this).offset();
var left = (e.pageX - offset.left);
var totalWidth = $("#custom-seekbar").width();
var percentage = ( left / totalWidth );
var vidTime = duration * percentage;
currentTime = vidTime;
}
有人可以告诉我如何解决它吗?