与reactjs导航路由不匹配

时间:2019-12-16 13:25:35

标签: javascript html reactjs

我是reactjs的新手,我试图在应用启动时加载我的侧边栏组件和仪表板组件。但是当我单击侧边栏按钮时,它只会加载该组件并隐藏我的侧边栏 下面是那个图片。 below is the pic of when app starting

below is the picture when i click sidebar button it only load the relavant component and sidebar was hidden..!

这是我的app.js

import React, {Component}from 'react';
 import './App.css';
import {BrowserRouter,Switch,Route} from "react-router-dom";
import Navbar from "./components/layout/Navbar";
import Signin from "./components/auth/SignIn/Signin";
import './App.css';
import New3 from "./components/new3/New3";
import Dashboard from "./components/dashboard/Dashboard";
import {StyleRoot} from "radium";
import Item from "./components/item/Item";
import Profile from "./components/profile/Profile";

function App() {
 return (
  <BrowserRouter>
    <StyleRoot>
      <div className="App">

        <Route path='/' exact component={Navbar} />
        <Route path='/' exact component={Dashboard} />
        <Route path='/signin' component={Signin} />

        <Switch>
          <Route path='/dashboard' component={Dashboard} />
          <Route path='/item' component={Item} />
          <Route path='/profile' component={Profile} />
        </Switch>

      </div>
    </StyleRoot>
     </BrowserRouter>
 );
}

export default App;

我如何解决这个问题

0 个答案:

没有答案