[英]My terminal is reading webpack compiled successfully but browser page is empty after connecting to react-dom
Here is my app.js这是我的 app.js
import Home from "./pages/home/Home";
import Login from "./pages/login/Login";
import Profile from "./pages/profile/Profile";
import Register from "./pages/register/Register";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
function App() {
return (
<Router>
<Routes>
<Route path="/">
<Home />
</Route>
<Route path="/login">
<Login />
</Route>
<Route path="/register">
<Register />
</Route>
<Route path="/profile">
<Profile />
</Route>
</Routes>
</Router>
);
}
export default App;
and here is my index.js (connections)这是我的 index.js(连接)
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
and the versions of react, react dom etc are mentioned below并且下面提到了 react、react dom 等的版本
{
"name": "ft-app-four",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-router-dom": "^6.3.0",
"react-scripts": "^5.0.1",
"web-vitals": "^2.1.4"
}
The terminal says You can now view ft-app-four in the browser.终端显示您现在可以在浏览器中查看 ft-app-four。
Local: http://localhost:3000本地:http://localhost:3000
On Your Network: http://192.168.42.136:3000在您的网络上:http: //192.168.42.136 :3000
Note that the development build is not optimized.请注意,开发版本未优化。 To create a production build, use npm run build.要创建生产版本,请使用 npm run build。
webpack compiled successfully webpack 编译成功
but I am unable to view anything on the browser screen但我无法在浏览器屏幕上查看任何内容
The way routing works in react-router
changed significantly between v5 and v6 . react-router
中路由的工作方式在 v5 和 v6 之间发生了显着变化。
The correct syntax for v6 is: v6 的正确语法是:
<Route path="/" element={<Home />} />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.