【问题标题】:How to pass multiple parameters with e.target in react js?如何在 react js 中使用 e.target 传递多个参数?
【发布时间】:2022-12-17 02:44:50
【问题描述】:

我在 react js 中有一个 onClick 函数,现在我想用 e.target 参数传递多个参数。如果我使用多个参数,则 e.target 无法正常工作。这个怎么做?

我的代码:-

export const App = () => {
  const move_box_click = (x, y, boxHeight, boxWidth, e) => {
    console.log(x, y, boxHeight, boxWidth);
    console.log (e.target.id)
  };

return(
<>
<input
type="input"
name={name}
value={value}
onClick={()=>move_box_click(100, 95, 30, 100)}
/>
</>
)
}

感谢您的努力!

【问题讨论】:

    标签: javascript reactjs


    【解决方案1】:

    还需要传递事件

    onClick={(event)=>move_box_click(100, 95, 30, 100,event)}
    

    【讨论】:

      猜你喜欢
      • 2022-01-06
      • 2022-01-19
      • 2020-11-24
      • 1970-01-01
      • 1970-01-01
      • 2015-08-16
      • 2018-05-02
      • 1970-01-01
      • 2019-09-04
      相关资源
      最近更新 更多