反应原生。参考错误:无法找到变量

时间:2018-05-08 15:09:02

标签: php mysql variables react-native reference

我在PHP MySql后端使用react-native。问题是我的应用程序没有从PHP接收数据并给出错误“参考错误:无法找到变量rowData”。我的代码如下:

componentDidMount() {



return fetch('http://192.168.xx.xxx/deliveryPerson/order.php')
  .then((response) => response.json())
  .then((responseJson) => {
    let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
    this.setState({
      //isLoading: false,
      dataSource: ds.cloneWithRows(responseJson),
    }, function() {
      // In this block you can do something with new state.
    });
  })
  .catch((error) => {
    console.error(error);
  });

  }

我在PHP JSON响应中的dataSource变量中有我的行

render() {

    return (
    <ScrollView style = { styles.bgColor }>

      <ListView
        dataSource={ this.state.dataSource }
        renderRow={(rowData) => 
      <View style = { styles.Container }>         


        <Text style = { styles.Font }>Name: {rowData.shop_name}</Text>[enter image description here][1]            

        <View style = { styles.flex }>
            <TouchableOpacity>
                <Text style = {styles.button}>
                Collect Payment
                </Text>
            </TouchableOpacity>

            <TouchableOpacity>
                <Text style = {styles.button}>
                View Order
                </Text>
            </TouchableOpacity>
         </View>              
      </View>
      }
    />
</ScrollView>
    );
  }
}

0 个答案:

没有答案