此问题可能有很多原因,但以下解决方法通常可以解决此问题:
npm run build
或
yarn build
http ://localhost:3000/#/home
,但在生产中,您需要使用真实的URL。使用BrowserRouter时,请确保您在服务器上的.htaccess文件(Apache)或Web.config文件(IIS)中正确配置路由。 下面是一个.htaccess文件的示例配置:Options -MultiViews
RewriteEngine On
## Send requests to React Router
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.html [L,QSA]
package.json
文件中设置 homepage
属性:{