更改默认的本地主机路径react
更改默认的本地主机路径。例如:http:// localhost:3001/by the Path http:// localhost:3001/home。我希望当我启动NPM启动时,我直接到达此路径http:// localhost:3001/home。我尝试在package.json文件中进行修改,但它不起作用。谢谢你的帮助
<BrowserRouter>
<Routes>
<Route path={"/"} />
<Route element={<ViewParentCustomer />} >
<Route path={RouteTypes.REDIRECT_HOME} element={<Home/>} />
<Route path={RouteTypes.ROUTE_OUR_HISTORY} element={<OurHistory />} />
<Route path={RouteTypes.ROUTE_COMMAND_CUSTOMER_ACCOUNT} element={<ProtectedRoutes ><DetailCommand /></ProtectedRoutes>} />
<Route path={RouteTypes.ROUTE_SIGNUP} element={<Registration />} />
<Route path={RouteTypes.ROUTE_FORBIDDEN} element={<AccessForbidden />} />
</Route>
</Routes>
</BrowserRouter>
change the default localhost path. For example: http://localhost:3001/ by the path http://localhost:3001/home . I would like the when I launch npm start that I arrive directly on this path http://localhost:3001/ home . I tried modifying in the package.Json file, but it doesn't work. Thank you for help
<BrowserRouter>
<Routes>
<Route path={"/"} />
<Route element={<ViewParentCustomer />} >
<Route path={RouteTypes.REDIRECT_HOME} element={<Home/>} />
<Route path={RouteTypes.ROUTE_OUR_HISTORY} element={<OurHistory />} />
<Route path={RouteTypes.ROUTE_COMMAND_CUSTOMER_ACCOUNT} element={<ProtectedRoutes ><DetailCommand /></ProtectedRoutes>} />
<Route path={RouteTypes.ROUTE_SIGNUP} element={<Registration />} />
<Route path={RouteTypes.ROUTE_FORBIDDEN} element={<AccessForbidden />} />
</Route>
</Routes>
</BrowserRouter>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
替换
为
导入:
Replace
with
Imports:
解决方案:
&lt;路由路径=“/” element = {&lt;导航到=“/pastry”/&gt; } /&gt; < /code>
the solution :
<Route path="/" element={ <Navigate to="/pastry" /> } />
您可以像这样重定向将其重定向:
在此处阅读有关
您可以使用
路由
。特别感谢 kapobajza :You can redirect it like this:
Read more about redirecting here
UPDATE:
You can use
Route
. Special thanks to Kapobajza: