美文网首页React Native实践
React Native ListView 长按删除

React Native ListView 长按删除

作者: 驰骋骏马 | 来源:发表于2016-11-28 11:42 被阅读0次

项目中React NativeListView的长按删除功能分享(基于ES5):

/**

* Sample React Native App

* https://github.com/facebook/react-native

* @flow

*/

importReact, {Component} from'react';

import{

AppRegistry,

StyleSheet,

Text,

View,

ListView,

TouchableOpacity

} from'react-native';

vards =newListView.DataSource({

rowHasChanged: (r1, r2) => {

r1 !== r2

}

});

varrows = ['row 1','row 2','row 3','row 4','row 5','row 6'];

varXXX = React.createClass({

getInitialState() {

return{

dataSource: ds.cloneWithRows(rows),

};

},

_deleteRow(rowID) {

deleterows[rowID];

this.setState({dataSource: ds.cloneWithRows(rows)})

},

renderRow(rowData, sectionID, rowID) {

returnthis._deleteRow(rowID)}

style={{height: 60, flex: 1, borderBottomWidth: 1}}>

{rowData}

},

render() {

return(

dataSource={this.state.dataSource}

renderRow={this.renderRow}

/>

);

}

});

AppRegistry.registerComponent('XXX', () => XXX);

本文原创地址:http://blog.csdn.net/chichengjunma/article/details/53331160

相关文章

网友评论

    本文标题:React Native ListView 长按删除

    本文链接:https://www.haomeiwen.com/subject/lskopttx.html