ionic - 为 web 构建,index.html 寻找不存在的文件

ionic - building for web, index.html looking for files that don't exist

我在使用 Ionic 时遇到问题。我过去为 iOS 和 Android 构建过,没有遇到任何问题。

我现在想在网络上托管我的离子项目,所以我正在尝试构建它生成的文件并将其上传到我的托管服务器。

我构建使用:

ionic build --prod

我也试过:

ionic cordova build browser --prod --release

我没有收到任何错误消息,所以我转到 platforms > browser > www 复制整个文件夹并将其上传到我的托管服务器。大约有 237 个文件。

上传后,我尝试访问它应该在 https://myurl.com/www/index.html 上的 url,但我收到错误提示,它正在寻找不存在的文件。

index.html:19 GET https://myurl.com/styles.eef8d0b037ae75ae3ee1.css net::ERR_ABORTED 404 (Not Found)

index.html:23 GET https://myurl.com/runtime-es2015.83b0bcbb60824f9bb8b4.js net::ERR_ABORTED 404 (Not Found)

index.html:19 GET https://myurl.com/styles.eef8d0b037ae75ae3ee1.css net::ERR_ABORTED 404 (Not Found)

index.html:23 GET https://myurl.com/main-es2015.002da15914054dfd59d6.js net::ERR_ABORTED 404 (Not Found)

我做错了什么?我只是上传 www 文件夹。我应该上传其他东西吗?

任何建议都很好。谢谢。

您似乎正在将网络文件上传到您主机的 'www' 文件夹:

https://myurl.com/www/index.html <-- 注意 'www' 这里。

虽然您的 index.html 最有可能指向基础 url 作为您域的根(404 错误说没有这样的文件等)。您的 index.hml 默认情况下会有这个:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <title>Ionic App</title>

  <base href="/" />
...
</head>

因此,要解决此问题,您需要: