class App extends React.Component { constructor() { } // 在回调函数中使用箭头函数,可添加参数 getName(name) { console.log(name); } render() { let name = 'RR'; return ( <> <button onClick={(name) => { this.getName(name) }}>姓名</button> // 或 <button onClick={function(name){ this.getName(name) }}>姓名</button> </> ) } }
【React】react学习笔记12-记录箭头函数的传值方法
猜你喜欢
转载自www.cnblogs.com/the-fool/p/11232558.html
今日推荐
周排行