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>

    }


胡子哥哥
浏览 1146回答 3
3回答

眼眸繁星

this.test.bind(this,&nbsp;args)

ABOUTYOU

onPress={()=>this.&nbsp;test("点击执行这个函数而不是立即执行")}

ITMISS

constructor(){&nbsp; &nbsp; &nbsp;....&nbsp; &nbsp; this.test.bind(this)}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript