javascript - NextJS:在 ExportPathMap 中设置动态路径
问题描述
我在不使用 getStaticPath 的情况下完成了 NEXT JS 项目,我正在尝试部署它。但是,我无法弄清楚如何在 ExportPathMap 中设置动态路径。我通过 获取参数数据useRouter()
,它在本地 100% 正确工作,但在部署版本上失败。
这是我的 next.config.js 文件:
const withImages = require('next-images')
module.exports = withImages()
module.exports = withImages({
images: {
loader: "imgix",
path: "",
},
exportPathMap: async function (
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
return {
'/': { page: '/' },
}
},
})
我的动态路径是 localhost:3000/[pid] 和 localhost:3000/[pid]/[jobid]。
我不知道如何使用 getStaticPath,因为文档引用了一些预加载的 JSON 数据,但我正在尝试实现其他目标。
解决方案
推荐阅读
- vue.js - Adonuxt.js 我的 js 库没有从静态文件夹中调用
- php - 注册后使用自定义闪现会话数据的 Laravel 自定义重定向
- javascript - 您可能需要适当的加载器来处理此文件类型:反应组件中的箭头函数
- python - How to speed up matplotlib, subplot plotting/drawing and saving?
- awesome-wm - 绘制后如何获取小部件的宽度和高度?
- cassandra - 具有多个字段的 Cassandra SASI 索引
- javascript - How to hide bar but keep datalabels HighCharts
- javascript - 如何将数据从 asp.net 传递到 javascript
- java - TreeMap 的自然排序不一致
- powershell - 使用 powershell 搜索 Outlook 电子邮件