import Head from 'next/head';
import { PostCard, Categories, PostWidget } from '../components'
const posts = [
{
title: "React Testing",
excerpt: "Learn React Testing"
},
{
title: "React with Tailwind",
excerpt: "Learn React with Tailwind",
},
];
export default function Home() {
return (
<div className="container mx-auto px-10 mb-8">
<Head>
<title>Create Next App</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<div className="grid grid-cols-1 lg:grid-cols-12 gap-12">
<div className="lg:col-span-8 col-span-1">
{posts.map((post) => <PostCard post={post} key={post.title} />)}
</div>
<div className="lg:col-span-4 col-span-1">
<div className="lg:sticky relative top-8">
<PostWidget />
<Categories />
</div>
</div>
</div>
</div>
)}错误是
键入'{ post:{ title: string;摘录: string;};键: string;}‘不能分配到键入'IntrinsicAttributes’。类型‘IntrinsicAttributes’..ts(2322)中不存在属性'post‘。
发布于 2022-10-14 17:15:40
它抱怨key道具是string,而它是用object传递的。
将其更改为如下所示,键应该是列表中唯一的支柱.
<div className="lg:col-span-8 col-span-1">
{posts.map((post) => <PostCard post={**post.some_unique_propname**} key={post.title} />)}
</div>https://stackoverflow.com/questions/74072573
复制相似问题