react打包 npm run build 出现空白页面
时间:2020-03-15 12:27:10
收藏:0
阅读:499
打包部署的路由配置
项目执行npm run build后,将打包后的build文件当大 Nginx 配置中。
如果 react-router 路由 使用了 history 模式(即<BrowserRouter>),那么在 Nginx 配置中必须加上:
location / {
··· ···
try_files $uri /index.html;
··· ···
}
}
如果 react-router 路由 使用了 hash 模式(即<HashRouter>),那么在 Nginx 中不需要上面的配置。
出现空白页面时只要把路径的BrowserRouter改成HashRouter即可
原文:https://www.cnblogs.com/nuister/p/12496570.html
评论(0)