React Native ListView的Item设置点击事件时null is not an object
来源:互联网 发布:淘宝链接生成器 编辑:程序博客网 时间:2024/06/14 18:44
先贴下代码:
<ListView contentContainerStyle = {styles.list} pageSize={2} dataSource = {this.state.dataSource} renderRow={this._renderRow} />_renderRow(rowData) { console.log('rowData.url: '+ rowData.url) ; console.log('rowData.name: '+ rowData.name) ; return ( <TouchableOpacity onPress = {() =>this._pressRow(rowData.url)} underlayColor = "transparent" > <View> <View style={styles.row}> <Text style={styles.text}> {rowData.name} </Text> </View> </View> </TouchableOpacity> ) }
ListView里的renderRow={this._renderRow},然后会报错,显示null is not an object (evaluating '_this3._pressRow')
,上图:
一看就知道是找不到方法,后来查阅这个资料,知道了解决方法,原来renderRow要与外面的this绑定起来,这个跟Android里的上下文环境Context很像:
<ListView contentContainerStyle = {styles.list} pageSize={2} dataSource = {this.state.dataSource} renderRow={this._renderRow.bind(this)} />
http://stackoverflow.com/questions/36303634/reactnative-tapping-row-in-listview-gives-error-cannot-read-property-pressr
0 1
- React Native ListView的Item设置点击事件时null is not an object
- React-native:Undefined is not an object
- React Native开发坑之null is not an object (evaluating 'inst.componentWillReceiveProps')
- 运行React Native示例出现null is not an object (evaluating 'this.state.text')
- React-Native之undefined is not an object
- 《React-Native系列》17、 RN中this所引起的undefined is not an object错误
- 《React-Native系列》17、 RN中this所引起的undefined is not an object错误
- React-Native 0.43.4 undefined is not an object (evaluating '_props[registrationName]') 正确的解决姿势
- React Native 出现undefined is not an object (evaluating 'this.props.navigator')
- React Native报错unddefined is not an object(evaluating ‘_reactnative.propTypes’)解决办法
- react-native-baidu-map undefined is not an object(evaluting 'a.PropTypes.bool')
- ListView的item点击事件
- listview为不同的item设置不同的点击事件
- 如何在ListView中设置item的点击事件
- listview中item的button设置两次点击事件
- ListView 中设置setonitemclicklistener()监听时,无法获取item条目的点击事件焦点
- react-native listview remove item
- dojo.widget' is null or not an object
- 从系统服务进程访问HKEY_CURRENT_USER主键
- css文本显示
- pure virtual析构函数
- 两种在web项目中获取读取文件的路径的方法
- 哈夫曼树 ACM
- React Native ListView的Item设置点击事件时null is not an object
- 第二章 怎样把android studio快捷键设置与eclipse一样
- 使用uiautomator的python封装进行android的UI测试
- opencv 图像减色
- Handler Looper MessageQueue
- 快学Scala第20章----Actor
- atoi() 函数解析
- c语言中关于n个元素的栈和c1赋不上值的问题
- IOS中UIScrollView的详细使用