reactjs - 下一个 js 从 Json 的特定项目中获取道具
问题描述
我有一个带有道具的 json 产品列表,我想通过他的 ID 将那个特定项目的道具带到另一个文件中。如果路线不是动态的,我该怎么做?(通常我会使用 router.query.id)。
这是 json 示例:
export const ArtroscopiaPlus = [
{
title: 'product 1',
url: 'https://drive.example1',
id: 'grapa-iql',
img: '/img/productos/Artroscopia/img1.jpg'
},
{
title: 'Product 2',
url: 'https://drive.example2',
id: 'kurosaca-romo',
img: '/img/productos/Artroscopia/img3.jpg'
},
{
title: 'Product 3',
url: 'https://drive.example3',
id: 'tornillo-transversal',
img: '/img/productos/Artroscopia/img4.jpg'
},
这是我可以注入该道具的代码:
const GrapaIQL = () => {
return (
<>
<ItemS>
<TitleItem className="title-item">{Prop with the title}</TitleItem>
<ContentItem>
<ImageDiv className="image-div">
<ItemImg src="{prop with the img}" alt={`${titulo} Company`} className="item-img" data-aos="fade-right" />
</ImageDiv>
<div className="info-div">
<table class="tabla-chica" data-aos="fade-left">
(not relevant table content)
</table>
</div>
<Pdf path='{Prop with the path}' />
</ContentItem>
<ScrollArrow />
</ItemS>
解决方案
推荐阅读
- .htaccess - 如果 URL 包含某些单词,如何重定向?
- angular6 - 在 Angular 6 上显示浏览器时,某些文本元素会出现延迟
- ios - 标签栏上的选定索引在 Swift 上不起作用
- java - 连接互联网或WiFi时如何实现对话框消失。反之亦然?
- flutter - 如何让你的文本在一行内换行?
- rust - 如何改变 move 传递的参数?
- python-3.x - 如何在 Visual Studio Code 中使用 activate.bat 而不是 ps1 运行选定文本?
- java - 如何更新 JsonObject 中的元素值?
- java - 如何解决 unirest java 中的 multipart/form-data 请求?
- macos - 如何使用苹果脚本执行 cd 命令