简体   繁体   English

选择多项 react.js 中的一项

[英]Choose one of multiple items react.js

I am trying to make a website for my portfolio and I need some help.我正在尝试为我的投资组合制作一个网站,我需要一些帮助。

What I want is the client to be able to click on one of pictures and select it and then to get redirected to another page with another options.我想要的是客户端能够单击其中一张图片和 select 它,然后使用其他选项重定向到另一个页面。

I think I should save the choice with a state, but I do not have the proper vision how to proceed.我想我应该用 state 保存选择,但我不知道如何继续。 Can you help me or give me an idea?你能帮助我或给我一个想法吗?

 <div className="landing_3"> <p className="msg_2"> Customize the perfect gift</p> <p className="msg_3"> Choose one of the options to start with: </p> <div className="landing_3_items"> <img alt="" src={c3} className="landing_img" /> <img alt="" src={c4} className="landing_img" /> <img alt="" src={c5} className="landing_img" /> </div> </div>

代码的结果

You can use the <Link> component from react-router-dom , like this:您可以使用react-router-dom中的<Link>组件,如下所示:

<Link to="mypage">
    <img src="" />
</Link>

You need to make a router for your application too.您还需要为您的应用程序制作一个路由器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM