首页 > 解决方案 > 根 id 中没有呈现任何内容

问题描述

我的页面上没有呈现任何内容,我很困惑。我想知道是否有人可以帮助我

应用程序.js:

import React from "react";
import Header from "../layout/Header/Header";
import Footer from "../layout/Footer/Footer.jsx";

import {
  BrowserRouter as Router,
  Route,
  Switch,
  Redirect
} from "react-router-dom";

import NotFound from "./NotFound";

import Home from "../pages/Home";
import Pricing from "../pages/Pricing";
import Contact from "../pages/Contact";
import About from "../pages/About";
import Dashboard from "../pages/Dashboard";
import Signin from "../pages/Signin";


class App extends React.component {
  render() {
    return (
      <>
        <div className="App">
          <Header />
          <Router>
            <App />
            <Switch>
              <Route exact path="/home" component={Home} />
              <Route exact path="/about" component={About} />
              <Route exact path="/contact" component={Contact} />
              <Route exact path="/pricing" component={Pricing} />
              <Route exact path="/dashboard" component={Dashboard} />
              <Route exact path="/signin" component={Signin} />
              <Route component={NotFound} />
              <Redirect from="/" to="home" />
            </Switch>
          </Router>
        </div>
        <Footer />
      </>
    );
  }
}

export default App;

这是我的 index.js:

import React from "react";
import { render } from "react-dom";

import App from "./components/App/App";

//import Signup from "components/pages/SignupBRUH";
import "./styles/styles.scss";

render(<App />, document.getElementById("root"));

我的项目也在使用护照,如果这有什么帮助的话。这可能是路线或其他方面的错误。我不知道。

如果有人可以为我解决这个问题,那就太好了,谢谢。

标签: javascriptnode.jsreactjsmern

解决方案


您可以尝试为 App 组件渲染以下内容,以确保模板连接正确

class App extends React.component {
  render() {
    return (
      <>
        <div>
            App Component
          </div>
      </>
    );
  }
}

推荐阅读