javascript - 根 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"));
我的项目也在使用护照,如果这有什么帮助的话。这可能是路线或其他方面的错误。我不知道。
如果有人可以为我解决这个问题,那就太好了,谢谢。
解决方案
您可以尝试为 App 组件渲染以下内容,以确保模板连接正确
class App extends React.component {
render() {
return (
<>
<div>
App Component
</div>
</>
);
}
}
推荐阅读
- rest - 如何使用 Content-Type "application/x-www-form-urlencoded" 发送 POST 请求
- javascript - 赛普拉斯命令行工具不支持参数
- python - Scrapy 导入真的很慢
- php - 无法刷新令牌,因为用户已更改 - Syfmony 4 - LDAP
- android - 为动态类型的 gson 创建一个 AdapterFactory
- reporting-services - 具有列和行范围的 SUM 表达式
- c - 未知类型名称“ETSTimer”
- ios - 无法让 WatchKit URLSession 背景工作
- python - 编译时出现错误的幻数
- pulseaudio - 网络脉冲音频