React Native引用错误:找不到变量

vktxenjb  于 2021-06-25  发布在  Mysql
关注(0)|答案(0)|浏览(365)

我将react native与php mysql后端结合使用。问题是我的应用程序没有从php接收数据,并给出错误“reference error:cannot find variable 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);
  });

  }

我在phpjson响应的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>
    );
  }
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题