React-Router Id 参数

问题描述

我正在尝试使用 react-router 动态呈现每篇博文。我从 Contentful API 获取两个博客。 BlogCards 组件用于通过卡片呈现博客。如何使用每个博客的 id 动态呈现每个博客

import React from 'react'
import '../BlogCards/BlogCard.scss'
import {Link}from 'react-router-dom'

function BlogCards() {
    return (
            <>
          
        <div className="blog-card__info">
          <h5>HARVICK GETS WHAT HE NEEDS,JOHNSON AMONG THOSE</h5>
        </div>
        <Link to='/blog'>
        <a href="#" className="btn btn--with-icon"><i className="btn-icon fa fa-long-arrow-right"></i>READ MORE</a>
        </Link>

    </> 
    )   
}

export default BlogCards

return (
        <div>
          <h1 className="header">Blog</h1>
          {blogs.map((blog)=>
            <Article key={blog.sys.id} title={blog.fields.title} introduction={blog.fields.introduction} mainBody1={blog.fields.mainBody1} mainBody2={blog.fields.mainBody2}  />
          )}
        </div>
    )

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)