Reactjs componentWillMount方法跳过函数调用
这是我的组件willmount-MethodReactjs componentWillMount方法跳过函数调用,reactjs,Reactjs,这是我的组件willmount-Method componentWillMount : function(){ this.refreshFunction this.state.autorefresh = window.setInterval( this.refreshFunction ,30000); } 这在很大程度上是按预期工作的,但是,第一个函数调用,因此,永远不会调用“This.refreshFunction”行 在稍后的时间间隔中使用完全相同的函数调用
componentWillMount : function(){
this.refreshFunction
this.state.autorefresh = window.setInterval(
this.refreshFunction
,30000);
}
这在很大程度上是按预期工作的,但是,第一个函数调用,因此,永远不会调用“This.refreshFunction”行
在稍后的时间间隔中使用完全相同的函数调用是完美的
有什么想法阻止React执行它吗?我还没有反应过来,不知道如何追踪这个问题你是否试着正确地称呼它
componentWillMount : function(){
this.refreshFunction();
this.state.autorefresh = window.setInterval(
this.refreshFunction
,30000);
}
你试着正确地称呼它了吗
componentWillMount : function(){
this.refreshFunction();
this.state.autorefresh = window.setInterval(
this.refreshFunction
,30000);
}
谢谢,这是完美的工作。我想我必须去掉括号,因为到目前为止,React类中的每个调用似乎都是在没有括号的情况下完成的。请解释一下,为什么在区间之外调用时必须使用括号?只有在传递函数作为引用时,才能省略括号。为了运行它,需要使用括号。谢谢,这非常有效。我想我必须去掉括号,因为到目前为止,React类中的每个调用似乎都是在没有括号的情况下完成的。请解释一下,为什么在区间之外调用时必须使用括号?只有在传递函数作为引用时,才能省略括号。为了运行它,需要括号。