You need to pass query parameter as per your folder structure i.e mysite.com/posts/12
As per documentation,Any route like /post/1
, /post/abc
, etc. will be matched by pages/post/[id].js
. The matched path parameter will be sent as a query parameter to the page, and it will be merged with the other query parameters.
For example, the route /post/abc
will have the following query object:
{ "id": "abc" }
Similarly, the route /post/abc?foo=bar
will have the following query object:
{ "foo": "bar", "id": "abc" }
However, route parameters will override query parameters with the same name. For example, the route /post/abc?id=123
will have the following query object:
{ "pid": "abc" }
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…