代码之家  ›  专栏  ›  技术社区  ›  jemz

onpress期间未定义预定义函数

  •  0
  • jemz  · 技术社区  · 6 年前

    我有问题,在onPress期间它会引发一个错误未定义的函数…等等。

    有人能帮我解释一下我的代码有什么问题吗。为什么我不能调用这个函数。

    提前谢谢你。

    _deleteRecord = (id) => {
    
            this.props.deleteRecord(id);
        }; 
    
    static navigationOptions = ({ navigation}) =>{
    return{
           headerRight: (
                    <IconIonicons
                        color="white"
                        name="md-trash"
                        size={24}
                        onPress={() =>this._deleteRecord(params.id)}
                        style={{color: '#ffffff', marginRight: 15}}
                    />
    
                ),
     }
    
    }
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Alessandro Macanha    6 年前

    改变 onPress={() =>this._deleteRecord(params.id)} onPress={this._deleteRecord(params.id).bind(this)}