【发布时间】:2021-10-06 14:33:24
【问题描述】:
我得到空结果。我做错了什么?
indx.js:
export default class Home extends React.Component {
static async getInitialProps(ctx) {
const test = 'test 123'
return {props: {test: test}}
}
render() {
console.log(this.props.test)
return (
<>
<h1>{this.props.test}</h1>
</>
)
}
}
_app.js:
function MyApp({ Component, pageProps }) {
return (
<Component {...pageProps} />
)
}
export default MyApp
在 'console.log' 上获取 undeifend 并且 'h1' 是 emtpy
【问题讨论】: