我构建了我的应用,但屏幕上没有任何内容。
我在页面之间使用了react-router作为路径,但是什么也没显示...
我的应用程序必须位于子文件夹中:文件夹/子文件夹/子文件夹为主要链接。
我不知道我哪里错了
这是我的路线:
<Router basename="/">
<div>
<Route exact path="/" component={App}/>
<Route path="/scene01" component={Scene01}/>
</div>
</Router>
我的package.json:
"name": "impermo",
"version": "0.1.0",
"private": true,
"homepage": "/folder/subfolder/subfolder/",
"dependencies": {
"@material-ui/core": "^4.9.12",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
答案 0 :(得分:0)
您需要从Switch
添加一个react-router
<Switch>
浏览其子项<Route>
,并呈现与当前URL匹配的第一个子项。
<Router basename="/">
<Switch>
<Route exact path="/" component={App}/>
<Route path="/scene01" component={Scene01}/>
</Switch>
</Router>