反应路由在反应样板中不起作用

时间:2018-09-09 13:48:17

标签: reactjs

我正在尝试路由,但无法正常工作,显示空白页 这是代码 当我按下localhost:3000 / home时,它什么也没显示

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


const Home = () =>{
  return(
      <div>
        <p>Home</p>
      </div>
  );
}

class App extends Component {
  render() {
    return (
      <Router>
        <Route path='/home' Component={Home}/>
      </Router>
    );
  }
}

export default App;

1 个答案:

答案 0 :(得分:0)

<Route />中的

component 道具区分大小写,请使其小写

class App extends Component {
render() {
    return (
      <Router>
        <Route path='/home' component={Home}/>
      </Router>
    );
  }