NextJS:与嵌套动态路由相关的问题(/category/[label]/subcategory/[id])
类别路径
http://localhost:3000/category/Municipality
选择类别[label]时的
http://localhost:3000/category/subcategory/44
,然后选择子类别[id],我在路径中失去了值[label],它只会向我显示以下路径: NextJS允许我在没有问题的情况下显示子类别信息,但是它所采用的路径不正确。
我想要这样的路:
http://localhost:3000/category/Municipality/subcategory/44
代码:示例
const path = `/category/subcategory/${directory?.id}`; // ??
return (
<List.Item key={directory.id}>
<Skeleton avatar title={false} loading={isLoading} active>
<Card cover={<Image src={`${config.SERVER_URL}${thumbnail?.attributes?.formats?.large?.url}`} />} style={{ width: 300 }} loading={isLoading}>
<Meta
title={<Link href={path}>{title}</Link>} // path to view subcategory information
description={description}
/>
</Card>
</Skeleton>
</List.Item>
);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要稍微更改文件夹结构,然后将其如下:
&lt; - 这是一个文件夹
在这里也是指向工作示例的链接
,也是您的代码示例中的
path
变量看起来不正确。我相信那应该是那样的You need to change the folder structure a little bit and make it like the following:
<-- this is a folder
Here is the link to the working example
Also in your code example, the
path
variable looks incorrect. I believe it should be something like that