react 调用带参的函数

函数:

showDate (data){ //获取到穿过来的data

console.log("data========================>"+data);

};

调用

方法一:箭头函数

<Button onClick={()=>this.showDate (1)}>点我</Button>  //这里的1就是传过去的参数

方法二:bind

<Button onClick={this.showDate .bind(1)}>11111111</Button> //这里的1就是传过去的参数

划重点:

箭头函数和bind的使用

发布了98 篇原创文章 · 获赞 19 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/water_Popcorn/article/details/98947111