小编A-M*_*Man的帖子

React-Native ListView onPress - undefined不是对象

我似乎在按下按钮时调用功能.无论我尝试什么方法,我都会得到不同的未定义错误.

我正在运行反应原生0.24,目前只编码Android设备.

请看下面的代码:

class ListPage extends Component {

   constructor(props){
   super(props);
       this.nav = props.nav;
       this.route = props.route;
       this.ds = new ListView.DataSource({
          rowHasChanged: (row1, row2) => row1 !== row2,
       });
       this.state = ({
           visible: false,
           dataSource: this.ds.cloneWithRows(props.fullList),
       });
  }

  goToPage(name){
      this.nav.push({ name: name });
  }

  loadModal() {
      this.setState({ visible: true });
  }

    list(row){
        return (
             <View style={styles.box}>
                  <TouchableNativeFeedback underlayColor="#FFF" 
                    onPress={this.goToPage.bind(this,'ShowRow')}>
                      <View>
                          ...ShowRow Button
                      </View>
                   </TouchableNativeFeedback>
                   <TouchableNativeFeedback
                      onPress={this.loadModal.bind(this)} >
                        <View style={styles.button}>
                            ...Modal Button
                        </View>
                   </TouchableNativeFeedback>
              </View>
          );
    }

    render(){
        return (
             <View style={styles.container}> …
Run Code Online (Sandbox Code Playgroud)

react-native

3
推荐指数
1
解决办法
3134
查看次数

标签 统计

react-native ×1