React Native Android隨筆日記

來源:互聯網
上載者:User

標籤: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隨筆日記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.