为什么当我在Apache上运行我的React构建...只是出现空白页..? [英] Why is that when i run my react build on Apache...Just blank page appears..?

查看:78
本文介绍了为什么当我在Apache上运行我的React构建...只是出现空白页..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序在节点服务器上运行正常,但是即使使用绝对路径,我在Apache服务器上也获得了空白页.

app is working fine in node server but i am getting blank page in Apache server even though i used absolute path.

这是index.html代码

Here is the index.html code

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
  <meta name="theme-color" content="#000000">
  <link rel="manifest" href="/manifest.json">
  <link rel="shortcut icon" href="/favicon.ico">
  <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
  <title>React App</title>
  <link href="./static/css/main.0778317d.css" rel="stylesheet">
</head>

<body>
  <noscript>You need to enable JavaScript to run this app.</noscript>
  <div id="root"></div>
  <script type="text/javascript" src="./static/js/main.1b4d826e.js"></script>
</body>

这是屏幕截图.

推荐答案

即使尝试了@Abdul Moiz提到的步骤,我也无法使用React Router v4在Apache主机上运行我的应用程序.

I was not able to get my app using React Router v4 to work on Apache hosting, even after trying the steps mentioned by @Abdul Moiz.

我找到了这个答案: https://stackoverflow.com/a/50657757/7867822

基本上将<BrowserRouter/>更改为<HashRouter/>对我有用.

Basically changing <BrowserRouter/> to <HashRouter/> worked for me.

这篇关于为什么当我在Apache上运行我的React构建...只是出现空白页..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆