【发布时间】:2021-05-13 08:29:49
【问题描述】:
我正在尝试使用 getStaticProps (Next.js) 呈现登录页面,但它的行为与预期不符。这是我的组件:
import { GetStaticProps } from 'next'
const Brief = (props) => {
console.log(JSON.stringify(props)) // returns an empty object
return (
<>
{props[0]}
{props[1]}
{props[2]}
</>
)
}
export const getStaticProps: GetStaticProps = async (context) => {
const WhatIUse = <div className="WhatIUse">What I use</div>
const introduction = <div className="introduction">Introduction</div>
const ContactInfo = <div className="ContactInfo">Where to find me</div>
return {
props: [introduction, WhatIUse, ContactInfo]
}
}
export default Brief
日志语句显示props 作为空对象返回,可能是什么问题?
【问题讨论】:
-
当你尝试运行它时肯定会出错?
-
完全没有,我正在运行生产版本,控制台中没有错误消息,只是元素没有显示。
-
您应该运行开发版本以确保您看到所有错误。
标签: typescript next.js