重定向React Router和Github页面

时间:2019-01-28 19:52:51

标签: reactjs github-pages react-router-v4

我正在尝试创建伪造的登录页面,并推测要转移到业务仪表板的页面。我正在尝试找出如何使其正确实现并部署到GitHub Pages。

basename是我在GH注册组件中的回购的名称,我有2个组件登录和注册

  render() {
return (
  <>
    <BrowserRouter basename="/dash">
      <Switch>
        <Route exact path="/" render={() => <Register />} />
        <Route
          path="/"
          render={() => (
            <>
              <div className="dashboard__grid">
                <TopNav />
                <SideNav />
                <main className="main">
                  <Route exact path="/campaigns" component={Campaigns} />
                  <Route exact path="/quicksms" component={QuickSMS} />
                  <Route exact path="/statistics" component={Statistics} />
                  <Route exact path="/reports" component={Reports} />
                  <Route exact path="/billings" component={Billings} />
                </main>
              </div>
              <MobileNav />
            </>
          )}
        />
      </Switch>
    </BrowserRouter>
    <ToastContainer />
  </>
); }}export default withNamespaces("common")(App);

这是我的注册组件

        <main className="registration">
      <aside className="registration__aside">
        <Aside />
      </aside>
      <section className="registration__form">
        <div className="registrationForm__title">
          <NavLink
            exact
            to="/"
            activeClassName="registrationForm__title__link--Active"
            className="registrationForm__title__link"
          >
            Log In
          </NavLink>
          <span className="registration__form--span">or</span>
          <NavLink
            exact
            to="/sign-up"
            activeClassName="registrationForm__title__link--Active"
            className="registrationForm__title__link"
          >
            Sign Up
          </NavLink>
        </div>
        <Route exact path="/" component={LogIn} />
        <Route exact path="/sign-up" component={SignUp} />
      </section>
    </main>

0 个答案:

没有答案