Bladeren bron

推送刷新iframe

zhouna 5 jaren geleden
bovenliggende
commit
20c2e42581
1 gewijzigde bestanden met toevoegingen van 7 en 5 verwijderingen
  1. 7 5
      src/components/PushEmbed/index.jsx

+ 7 - 5
src/components/PushEmbed/index.jsx

@@ -8,7 +8,8 @@ class PushEmbed extends Component{
     super(props);
     this.state={
       height:100,
-      width:'100%'
+      width:'100%',
+      hashNum:0
     }
   }
   componentDidMount() {
@@ -21,14 +22,15 @@ class PushEmbed extends Component{
   }
   componentWillReceiveProps(next){
     if(next.update!=this.props.update){
-      //window.frames['embedPage'].contentWindow.location.reload();
-      //console.log(window.frames['embedPage'].contentWindow)
+      this.setState({
+        hashNum:Math.random()
+      });
     }
   }
   render(){
-    const {width,height}=this.state;
+    const {width,height,hashNum}=this.state;
     const {mrId} = this.props;
-    const url = "http://192.168.2.241:5448/index.html?mrId="+mrId+"&plan=1";
+    const url = "http://192.168.2.241:5448/index.html?mrId="+mrId+"&plan=1&data="+hashNum;
     return <iframe id='embedPage' width={width} height={height} src={url} frameborder="0"></iframe>;
   }
 }