javascript Localhost/home未显示显示输出

jei2mxaa  于 2022-12-28  发布在  Java
关注(0)|答案(1)|浏览(119)

我刚开始做网页开发。当我试着执行npm start命令时,我在localhost/home上没有输出。我想它在App.js文件上,我只是现在不明白。请帮助我的网页开发之神朋友们。

import logo from './logo.svg'
import './App.css';
import Navbar from './components/Navbar';
import React from 'react'
import {BrowserRouter, Route , Link, Routes} from 'react-router-dom';
import Homescreen from './screens/Homescreen';

function App() {
  return (
    <div className="App">
        <Navbar/>
          <BrowserRouter>
            <Routes>
              <Route path ="/home" exact component={Homescreen}></Route>
            </Routes>  
          </BrowserRouter>
    </div>
  );
}

export default App;
import React from 'react'

function Homescreen() {
  return (
    <div>
        <h1>Home screen</h1>
    </div>
  )
}

export default Homescreen

rqqzpn5f

rqqzpn5f1#

您错误地在path(path ="/home”)前添加了空格

<Route path ="/home" exact component={Homescreen}></Route>
<Route path="/home" exact component={Homescreen}></Route>

相关问题