在react-native中我們經(jīng)常要進(jìn)行判斷,然后決定視圖的顯示方式勾哩,所以就會(huì)經(jīng)常出現(xiàn)下面這樣的代碼:
renderChanged(){
return(
this.showPro()
);
}
showPro(){//進(jìn)度條
return(
<View style={{marginTop: 200,flexDirection:'row'}}>
<View style={{marginRight:10,height:16,width:ScreenWidth - 120}}>
<View style={styles.progressLabel}>
<Text style={{textAlign:'center',}}>{this.state.progress}</Text>
</View>
<View style={[styles.progressView,{width:(ScreenWidth - 150) * this.state.progress }]}></View>
</View>
<TouchableOpacity style={styles.cancleButton}
onPress={this.cancleClick.bind(this)}
></TouchableOpacity>
</View>
);
}```
如果第一個(gè)方法里面不加入return();,第二個(gè)方法里面的視圖是不會(huì)顯示抗蠢,我就在這個(gè)地方糾結(jié)了半天,最后還是靈光一閃發(fā)現(xiàn)的思劳,希望幫助大家少走彎路迅矛,節(jié)省時(shí)間!