我想定期重新加載iframe,但我使用React,所以我不能直接操縱DOM。這似乎是我最好的選擇是使用forceUpdate(),因爲url不會改變,所以我不能使用狀態更改來更新它(請參閱前一篇文章What's the best way to periodically reload an iframe with React?)。 但是,當我嘗試做一個forceUpdate()它不會重新呈現我的組件。任何想法爲什麼?如何正確使用forceUpdate()?
var Graph = React.createClass({
componentDidMount: function() {
setInterval(function(){
this.forceUpdate();
}.bind(this), 5000);
},
render() {
return (
<iframe src="http://play.grafana.org/dashboard/db/elasticsearch-metrics" width="1900px" height="700px"/>
)
}
});
在這裏看到的codepen:http://codepen.io/anon/pen/ggPGPQ
**我知道grafana可以設置爲自動更新,我只是用這個作爲一個例子iframe中。
變化主要特性對於