【发布时间】:2021-12-23 09:41:51
【问题描述】:
我有来自 postgresql 的对象:
需要像这样在 NextJS 组件上获取 id、名称和内容:
export async function getServerSideProps() {
const data = await prisma.note.findFirst()
return {
props: {
userNote: data,
},
}
}
interface INote {
id: number
name: string
content: string
}
const Home = ({ name, content, id }: INote) => {
console.log(name)
return <div>hello world</div>
}
但我没有定义。怎么了?
【问题讨论】:
-
你是如何渲染这个
Home组件的? -
"Home" 是 pages/index.tsx 中的主要组件
-
我可以得到这个对象 if = (userNote: any) => { ... } 但这是错误的
标签: typescript next.js prisma