我对React.js很陌生,我对React路由有疑问。
共有3条路线,/, /profile, /profile/edit
。当我尝试刷新/ profile / edit时,它在控制台中因以下错误而变为空白:error message
从我从错误中了解的内容来看,这些js文件是构建文件!
这是我的路由器代码:
<BrowserRouter>
<Switch>
<Route
exact
path="/"
component={() => this.renderPage()}
/>
<Route
exact
path="/profile"
component={() => this.renderPage()}
/>
<Route
exact
path="/profile/edit"
component={() => this.renderPage()}
/>
</Switch>
</BrowserRouter>
这是renderPage的代码:
renderPage() {
return (
<div></div>
);
}
这一直有效,直到如上所述刷新我的/ profile / edit页面。此错误仅在部署应用程序时显示,它在localhost上运行良好。
有帮助吗?