- 这是我的页面users. js**
import React from 'react'
const users = ({users}) => {
return (
<> {
users.map(user => {
return <div key={user.id}> {user.name} </div>
})
}
</>
)
}
export default users
export async function getStaticProps() {
const res = await fetch('https://jsonplaceholder.typicode.com/users')
const users = await res.json()
console.log("users", users)
return {
props: {
users,
},
// Next.js will attempt to re-generate the page:
// - When a request comes in
// - At most once every 10 seconds
revalidate: 10, // In seconds
}
}
- 当我运行此程序时,我在终端中收到以下错误,而我如何在终端中查看用户值?**
`error - SyntaxError: Invalid Unicode escape sequence
at eval (<anonymous>)
at oo_oo (webpack-internal:///./pages/users.js:50:14)
at users (webpack-internal:///./pages/users.js:14:5)
at renderWithHooks (C:\Users\udays\Documents\NEXTLEARN\next-pre-render\node_modules\react-dom\cjs\react-dom-server.browser.development.js:5658:16)
`
我试着去评论
` reactStrictMode: true,`
但没有成功。
您的帮助是非常感谢!!
1条答案
按热度按时间sdnqo3pr1#
尝试添加一些类似的错误处理。