Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/450.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript _这个函数不是一个函数_Javascript_React Native - Fatal编程技术网

Javascript _这个函数不是一个函数

Javascript _这个函数不是一个函数,javascript,react-native,Javascript,React Native,我在react native上工作,出现以下错误: _此6.callGeocodage不是一个函数 我的代码: callGeocodage(adress) { console.log(adress); } renderAd(item, index) { return ( <Card style={{ elevation: 3, width: Dimensions.get('window').width}}> <CardItem c

我在react native上工作,出现以下错误:

_此6.callGeocodage不是一个函数

我的代码:

callGeocodage(adress) {
 console.log(adress);
  }

  renderAd(item, index) {
    return (
      <Card style={{ elevation: 3, width: Dimensions.get('window').width}}>
        <CardItem cardBody>
          <TouchableOpacity onPress={() => {this.callGeocodage(item.adress)}}>
            <IconFontAwesome name={ICON_SEARCH} />
          </TouchableOpacity>
          <Text>{item.adress} </Text>
        </CardItem>
      </Card>
    );
  }

有人知道为什么吗???

您必须将此绑定到构造函数中的renderAd:

constructor(props){
   super(props);
   this.renderAd = this.renderAd.bind(this);
}
或将其用作箭头函数:

const renderAd = (item, index) => {

尝试在构造函数中绑定callGeocodage函数,如下所示。callGeocodage=this.callGeocodage.bindthis;按如下方式编写函数:callGeocodage=address=>{console.logaddress;};请告诉我们renderAd是怎样的called@MartinShishkov不,问题不是它没有绑定,而是找不到它。我尝试使用renderAd=item,index=>{,没关系,谢谢