我想從外部調用Json內部的函數。我想觸發按鈕「onClick」方法上的「下一個」功能。這是我的代碼。我試着用onClick = {this.next}來調用它,但它永遠不會被這個方法調用。調用另一個函數內部的函數
export default class PlayerLogic extends Component{
componentDidMount() {
var self = this;
var player = videojs(this.refs.video, this.props.options).ready(function() {
self.player = this;
self.player.on('play', self.handlePlay);
});
player.markers({
onMarkerReached: function() {
player.pause();
},
next : function() {
// go to the next marker from current timestamp
console.log("reached")
var currentTime = player.currentTime();
for (var i = 0; i < markersList.length; i++) {
var markerTime = setting.markerTip.time(markersList[i]);
if (markerTime > currentTime) {
player.currentTime(markerTime);
break;
}
}
}
});
}
render() {
return (
<div>
<video {... props}>
<source src={this.props.src} type={this.props.type} id={this.props.id}/>
</video>
<button onClick={this.next}>Next</button>
</div>)
}
};
這看起來像一個反應擴展 – Tibrogargan