【问题标题】:Why working PWA on Android Chrome and Firefox becomes white screen on iOS Safari?为什么在 Android Chrome 和 Firefox 上工作的 PWA 在 iOS Safari 上会变成白屏?
【发布时间】:2019-12-30 15:02:33
【问题描述】:

我已经在 11/12.4 版本的 iOS 设备上尝试过 Angular 7 和 8,甚至是 Ionic。所有相同的结果:这个 PWA 网络应用程序在 android Chrome 和 Firefox 上运行良好,但是当我在主屏幕上添加这个网页时,我只得到白屏。

这是我的 package.json

{
  "name": "caiex-angular6",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxyconfig.json",
    "build": "ng build --base-href ./",
    "buildTest": "ng build  --prod --build-optimizer --configuration=test",
    "buildProd": "ng build --prod --build-optimizer --configuration=production",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.3",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "babel-polyfill": "^6.26.0",
    "core-js": "^2.5.4",
    "crypto-js": "^3.1.9-1",
    "echarts": "^4.1.0",
    "element-angular": "^0.7.6",
    "jsrsasign": "^8.0.12",
    "ngx-echarts": "^4.1.0",
    "rxjs": "6.0.0",
    "rxjs-compat": "6.0.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.13.7",
    "@angular/cli": "~6.0.8",
    "@angular/compiler-cli": "^6.0.3",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }
}

这是我使用ng add @angular/pwa得到的index.html

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

<head>
  <meta charset="utf-8">
  <meta http-equiv="Access-Control-Allow-Origin" content="*">
  <title>My PWA</title>
  <base href="/">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <meta name="format-detection" content="telephone=yes" />
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link rel="stylesheet" href="./assets/css/iconfont.css">
  <script>
    document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + "px";
  </script>
</head>

<body>
  <app-root></app-root>
</body>

</html>

我可以在 Mac Chrome 和 Safari 上调试这个,但在 iOS Safari 上没有运气,因为它还不能很好地支持 PWA 调试。

【问题讨论】:

    标签: ios angular safari progressive-web-apps


    【解决方案1】:

    iOS 有很多关于 PWA 支持的公开部分。你有任何控制台错误吗?是否可以通过浏览器正确查看 Web 应用清单?

    您使用的是哪个版本的 Safari? 在can I use 网站上,您可以验证支持服务工作者的 Safari 版本。

    【讨论】:

      【解决方案2】:

      在 package.json 中,"babel-polyfill": "^6.26.0" 是 Safari 出现白屏的原因。如果你没有在你的 Angular 项目中使用任何 babel 语法,删除它会解决这个问题。

      【讨论】:

        猜你喜欢
        • 2012-02-05
        • 1970-01-01
        • 1970-01-01
        • 2016-02-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-20
        相关资源
        最近更新 更多