初學RN --點擊事件

第一次用TouchableHighlight報了這個錯:


各種百度差資料問群,然后莫名其妙的就解決了。發現根本原因是因為沒有執行this.方法名.bind(this),本人理解RN調用this需要先綁定了才能調用,最開始是這樣的this.renderRowShowView


renderScene(route, navigator) {

return(

dataSource={this.state.dataSource}

renderRow={this.renderRowShowView.bind(this)}

style={styles.listView}

/>

);

}

renderRowShowView(showModel,sectionID,rowID)

{

return(

onPress={()=>this.gotoPersonPage(rowID)}

underlayColor= '#fff'

>

source={showModel.imageName}

style={styles.thumbnail}

/>

{showModel.title}

);

}

gotoPersonPage(index) {

if(index ==0)

{

}else if(index ==1)

{

this.props.navigator.push({

id:'BillQuery',

name:'掛失票據查詢',

});

}

}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容