gpt4 book ai didi

next.js - 下一个 : Multiple children were passed to with `href` of 'x' but only one child is supported

转载 作者:行者123 更新时间:2023-12-05 01:56:55 26 4
gpt4 key购买 nike

我没有将多个 child 传递给链接,为什么会出现此错误?错误是:“通过 /post/61703ea640ff7eef1e1e7e75href 传递给多个 child ,但只支持一个 child ”

return (
<>
{head()}
<div className="container-fluid"
style={{
backgroundImage: "url( "+ "/images/default.jpg"+ ")",
backgroundAttachment: "fixed",
padding: "100px 0px 75px 0px",
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
backgroundPosition: 'center center',
display: 'block'
}}>
<h1 className="display-1 font-weight-bold text-center py-5">MERNCAMP</h1>
</div>
<div className="container">
<div className="row pt-5">
{posts.map((post) => (
<div key={post._id} className="col-md-4">
<Link href={`/post/view/${post._id}`}>
<a>
<PostPublic key={post._id} post={post} />
</a>
</Link>
</div>
))}
</div>
</div>
</>
)

最佳答案

用一个div包裹整个链接

<Link key={post._id} href={`/post/${post.slug.current}`}>
<div>
<div>
<img src={urlFor(post.mainImage).url()} alt=''></img>
</div>
<div>
<p>{post.title}</p>
<p>
{post.description} by {post.author.n`enter code here`ame}
</p>
</div>
<img src={urlFor(post.author.image).url()!} alt=''></img>
</div>
</Link>

关于next.js - 下一个 : Multiple children were passed to <Link> with `href` of 'x' but only one child is supported,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69667347/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com