【发布时间】:2021-06-11 11:29:06
【问题描述】:
我在反应原生类组件中有两个功能。我尝试通过调用 test1() 来获取返回值,但它没有显示返回值。如果直接调用 test2(),我可以得到返回值。但是这两个函数中都会有很多 if else 条件和返回值,所以我需要调用函数 test1( )... 有人可以帮忙吗?
test1(){
this.test2()
}
test2(){
return(
<Text>Testing123</Text>
)
}
render{
return(
<View>
{this.test1()}
</<View>
)
}
【问题讨论】:
-
需要返回值,替换为
return this.test2()。您还需要绑定this。 tr.reactjs.org/docs/handling-events.htmlfreecodecamp.org/news/…