標籤:sel ati ret ica self turn get bottom on()
1、以前做Listview 的時候都會有一個捲軸,不由分說,很醜,以前想要去掉卻無從下手,
今日偶然發現Scrollview有兩個屬性
showsHorizontalScrollIndicator bool
當此屬性為true的時候,顯示一個水平方向的捲軸。
showsVerticalScrollIndicator bool
當此屬性為true的時候,顯示一個垂直方向的捲軸。
一定要記得試一下。果然有用,驗證成功。
2、一些簡潔的代碼文法老會忘記怎麼寫,現發現一條就記錄一條
<View style={[styles.innerContainer, {marginBottom:47}]}></View>
<Text style={{color:‘red‘}}>{this.state.second>=0?this.state.second:‘重發驗證碼‘}</Text>
<Text style={this.state.selectstate==0?styles.presstextnianfen:styles.textnianfen}>全部</Text>
<Image source={rowData.currentscore>1?require(‘../home/icon_star_yellow.png‘):require(‘../home/icon_star_grey.png‘)} style={{width:15,height:15,marginRight:2}}/>
<View style={{width:150,height:150,backgroundColor:this.state.selectcenterstate[rowID]==0? "#E9E6E6":"#D2EDF6",borderRadius:5,flexDirection:‘column‘}}>
3、關於如何在pop頁面後觸動更新的問題
一個很好的解決辦法從A頁面push到B頁面,傳一個重新整理的函數過去,這樣從B頁面pop回A頁面的同時,調用該函數。
例如A頁面代碼:回呼函數中傳一個重新整理的函數fetchstorise()
pusheditcenter(talkmsg){ let _this = this; this.props.navigator.push({ name:‘editcenter‘, component:TrainerselfCenterEdit, params:{ talkmsg:talkmsg, getparams: function(){ _this.fetchStories(); } } })}
B頁面代碼,在pop的時候調用該回呼函數
pushback(){ const { navigator } = this.props; if(this.props.getparams) { this.props.getparams(); } if(navigator) {//出棧,返回到上一頁 navigator.pop(); } }
4、關於如何使用定時器
寫這個的原因是因為RN的發展速度過快,文法變,使用方法也相應改變,現在這裡使用最新的es6的文法
componentDidMount(){ this.timer=setTimeout( ()=>{ this.setState({content:‘這是定時器列印的內容‘ }) },2000 ); this.timer_two=setTimeout( ()=>{ this.setState({msg:‘這是定時器列印的第二段內容‘}) },4000 ); } componentWillUnMount(){ this.timer&&clearTimeout(this.timer); this.timer_two&&clearTimeout(this.timer_two); } render() { return ( <View style={{margin:20}}> <Text>{this.state.content}</Text> <Text>{this.state.msg}</Text> </View> ); }
注意:定時器功能比較簡單,注意在es6中使用時,需銘記在unmount組件時清除(clearTimeout/clearInterval)所有用到的定時器。
React Native Android隨筆日記