我在GitHub页面中部署的React项目始终显示我的NotFound组件

时间:2018-06-10 09:37:43

标签: reactjs github-pages

我已经遵循了如何在GitHub页面中部署我的React项目的简单而正确的步骤,例如:https://github.com/gitname/react-gh-pages

不幸的是,我不知道为什么我的网站无法运行。它总是显示我的NotFound.js组件,在控制台中没有任何错误。已部署的站点为:https://krizferre.github.io/fewd-techdegree-project-11/

以下是我项目的代码段:

class App extends Component {

    // All routes re-use one component which is Container, just depends on the keyword/category being searched
    // Home path '/' is redirected to '/cats' to initially have photos to display
    render() {
      return (
        <BrowserRouter>
          <Switch>
            <Route exact path="/" render={ () => <Redirect to='/cats' /> } />
            <Route exact path="/search" render={ () => <Redirect to='/search/panda' /> } />
            <Route exact path="/search/:keyword" render={ props => <Container 
                                                                title='Results for ' 
                                                                keyword={props.match.params.keyword} 
                                                              />
                                                  } 
            />
            <Route exact path="/cats" render={ () => <Container title='Cat Gifs' keyword='cats' />} />
            <Route exact path="/dogs" render={ () => <Container title='Dog Gifs' keyword='dogs'/>} />
            <Route exact path="/birds" render={ () => <Container title='Bird Gifs' keyword='birds' />} />
            <Route component={NotFound} />
          </Switch>
        </BrowserRouter>
      );
    }
}

我的所有项目代码都在https://github.com/krizferre/fewd-techdegree-project-11/tree/gh-pages

谢谢

0 个答案:

没有答案