这个问题可能是因为iPhone和一些设备不支持ES5。Angular默认编译器是使用ES5编译器,因此解决方法是使用ES6编译器。在angular.json文件中,修改“target”属性为“es2015”,示例如下:
"build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/my-app", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.app.json", "assets": [ "src/favicon.ico", "src/assets" ], "styles": [ "src/styles.css" ], "scripts": [] }, "configurations": { "production": { "fileReplacements": [ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.prod.ts" } ], "optimization": true, "outputHashing": "all", "sourceMap": false, "extractCss": true, "namedChunks": false, "aot": true, "extractLicenses": true, "vendorChunk": false, "buildOptimizer": true, "budgets": [ { "type": "initial", "maximumWarning": "3mb", "maximumError": "5mb" } ] } }, "defaultConfiguration": "production", "target": "es2015" // 修改 "es5" 为 "es2015" }