我正在使用 React 构建网页,这意味着我无法直接操作 DOM。我尝试通过更新 url 状态来重新加载 iframe,但这似乎并没有重新加载页面。这是我尝试过的状态代码。
componentDidMount: function() {
setInterval(function(){
this.setState({currentUrl:currentUrl});
}.bind(this), 1000);
},
getInitialState: function() {
return {defaultUrl:this.props.graph.url, currentUrl:this.props.graph.url};
},
render() {
// render the graph iframe
return (
<iframe src={this.state.currentUrl} id={this.props.graph.url} style={this.props.style} width={this.props.width} height={this.props.graph_height} />
)
}