反应JS路径路径不起作用

时间:2018-06-11 04:16:24

标签: reactjs react-router

我无法导航到它没有回应的路径路径我不知道为什么。任何人都知道我的代码有什么问题。它只是加载着陆页,而且它无法加载其他组件

import React, { Component } from "react";
import { BrowserRouter as Router, Route } from 'react-router-dom';

import Navbar from "./components/layout/Navbar";
import Footer from "./components/layout/Footer";
import Landing from "./components/layout/Landing";
import Register from "./components/auth/Register";
import Login from "./components/auth/Login";
import "./App.css";


class App extends Component {
  render() {
    return (
      <Router>
        <div className="App">
          <Navbar />
          <Route path="/" component={Landing} />
          <div className="container">
          <Route path="/register" component={Register}/>
          <Route path="/login" component={Login}/>
          </div>
          <Footer />
        </div>
        </Router>
    );
  }
}

export default App;

1 个答案:

答案 0 :(得分:2)

exact添加到初始路线,否则会被所有路径捕获,

<Route exact path="/" component={Landing} />