ES6中不用匿名函数如何传递参数,而且不立即执行呢

  test(...arg) {
        console.log("参数",arg);
    }
    
 render(){
        return <View style={{flex:1,backgroundColor:"blue"}}>
            <TouchableOpacity activeOpacity={1} 
            onPress={this. test("点击执行这个函数而不是立即执行")}>//不适用箭头函数 有没有其他方式呢?
                <Text>hahahahhahahahahahha</Text>
            </TouchableOpacity>

        </View>
    }
阅读 2.7k
3 个回答
this.test.bind(this, args)
onPress={()=>this. test("点击执行这个函数而不是立即执行")}
constructor(){
     ....
    this.test.bind(this)
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题