Follow

#4. 对于Function Comp里面多个elements,想要根据点击不同的element而获取不同的数据, 参考{plans.map((plan,index) =>(
<Box
margin={2}
key={index}
style={{width: "100%"}}
onClick={() => handleCardClick(plan)}
>

其中onClick内部用arrow function, 不用传递event作为参数;其次,当plan本身是一个JSON OBJ的时候,不用在传递函数params的时候写成{plan},否则会返回plan:{.......} 而不是{...}

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.