【发布时间】:2020-04-26 05:19:51
【问题描述】:
我已经设置了exportPathMap,但是从我的组件导出getStaticProps 时得到一个空对象。我不明白我应该如何访问它?
// next.config.js
exportPathMap: async function (
defaultMapPath,
{ dev, dir, outDir, distDir, buildId }
) {
const paths = {}
const response = await fetch(...)
const data = await response.json()
data.forEach((item) => {
paths[`/item/${item.id}`] = {
page: '/itemPage',
query: {
item,
},
}
})
return paths
},
和
// itemPage.js
...
export async function getStaticProps(props) {
console.log('props', props) // returns "props {}""
return {
props: props
}
}
...
【问题讨论】: