我找到了类似的SO Post和unanswered post,但是,当您需要动态路径(路径参数)时,您会怎么做?
与/calendar/:year/:month/:day/event
类似,例如,/calendar/11/4/21/event
答案 0 :(得分:1)
The basename
that you can pass to a router (e.g. <BrowserRouter basename='/thing'>
) is not dynamic. You should think of the basename as the static path to the root directory where your app is located (although this might not be a literal path since you're most likely using a dynamic server).
Occasionally I have seen requests for dynamic basenames, usually when someone has language sections of their site (example.com/en/about
and example.com/zh/about
). The usual reason for wanting to include this information in the basename
is so that it doesn't have to be included in URIs. However, the basename
isn't supposed to contain information about the route; any data that isn't going to be the same for every single route in your application should not be part of the basename.