相关疑难解决方法(0)

react-router在生产和浪涌部署中不起作用

我的react应用程序在localhost上运行正常,但是当我在gh-pages中部署它或者激增之后它不会让我在使用URL的页面之间移动.

用户可以通过单击右上角的menuItem进入注册页面.但如果用户使用http://chat.susi.ai/signup/ URL,则会显示404页面

我尝试了几种来自互联网的解决方案,但没有用.

接下来的问题是:我创建了一个404页面,以便在用户尝试移动到损坏的链接时显示.它在localhost中正常工作.但不是在生产中.我试过这个解决方案,但没有改变.

这是我的index.js文件的一部分

const App = () => (
    <Router history={hashHistory}>
        <MuiThemeProvider>
            <Switch>
                <Route exact path="/" component={ChatApp} />
                <Route exact path="/signup" component={SignUp} />
                <Route exact path="/logout" component={Logout} />
                <Route exact path="/forgotpwd" component={ForgotPassword} />
                <Route exact path="*" component={NotFound} />

            </Switch>
        </MuiThemeProvider>
    </Router>
);

ReactDOM.render(
    <App />,
    document.getElementById('root')
);
Run Code Online (Sandbox Code Playgroud)

如果有人可以为我的问题建议使用示例代码的良好解决方案,这对我来说真的很有帮助.

javascript reactjs react-router react-router-dom

8
推荐指数
3
解决办法
9245
查看次数