【发布时间】:2020-06-01 19:29:36
【问题描述】:
第一次尝试部署到 firebase 时,我查看了 youtube 上的很多指南,stackoverflow 的做法与他们相同,但部署应用后总是出现空白页。
这是我的流程:
-纱线构建
-firebase 登录
-firebase 初始化
这就是我填充初始化的方式:
- 托管:配置和部署 Firebase 托管站点
2.你想用什么作为你的公共目录?构建
3.配置为单页应用(将所有url重写为/index.html)?否
4.文件 build/404.html 已经存在。覆盖?否
5.文件 build/index.html 已经存在。覆盖?(y/N)否
我尝试了几种方法,有时我将其中一些更改为 Yes,结果仍然相同
-firebase 部署
这是我的路由器的代码:
const App = () => {
return (
<div>
<Switch>
<Route path="/" exact component={Home} />
<Route path="/about" exact component={About} />
<Route path="/brands" exact component={Brands} />
<Route path="/guide" exact component={Guide} />
<Route path="/contact" exact component={Contact} />
<Route
render={function() {
return <p>Not found</p>;
}}
/>
</Switch>
</div>
);
};
我遇到的错误:
更新:
这是现在的屏幕:
更新:
新的错误:
【问题讨论】:
-
你应该做的是重定向到 index.html create-react-app.dev/docs/deployment/#firebase
-
@AlexanderStaroselsky 仍然给我空白页..
-
如果是空白页,请检查浏览器的开发工具。它可能正在渲染 HTML,但遇到了 JavaScript 问题。
-
@abraham 它没有告诉我开发工具不知道为什么,但控制台中有错误.. 我编辑帖子并添加了屏幕截图。您认为这是问题的原因吗?
-
这个错误意味着那些被填充的 JavaScript 没有被部署或者不是 HTML 试图从中加载它们的地方。也许尝试再次构建和部署。
标签: reactjs firebase react-router firebase-hosting