Angular应用程序在更新到v15后在Safari中无法工作
创始人
2024-10-30 14:30:40
0

问题是由Safari中使用的默认类型检测器引起的。在更新到Angular v15之后,您需要手动引入polyfill来解决。

要解决这个问题,请在src/polyfills.ts文件中添加以下代码:

(window as any).__type = (value: any) => {
    try {
        return {}.toString.call(value).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
    } catch (err) {
        return typeof value;
    }
};

然后在angular.json文件的build选项中添加以下内容:

{
  "build": {
    "builder": "@angular-devkit/build-angular:browser",
    "options": {
        "allowedCommonJsDependencies": ["typescript"],
        "assets": ["src/favicon.ico", "src/assets"],
        "outputPath": "dist/example",
        "index": "src/index.html",
        "polyfills": "src/polyfills.ts",
        "main": "src/main.ts",
        "tsConfig": "src/tsconfig.app.json"
    },
    "configurations": {
        ...
        "production": {
          ...
          "fileReplacements": [
              {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
              }
          ],
          "optimization": {
            "scripts": true,
            "styles": {
                "minify": true,
                "inlineCritical": true
            }
          },
          "outputHashing": "all",
          "sourceMap": false,
          "extractCss": true,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true
        },
        ...
    }
  }
}

现在重新构建应用程序即可在Safari中正常工作。

相关内容

热门资讯

实测分享!wepoker透视有... 实测分享!wepoker透视有没有(辅助挂)确实真的有挂(今日头条)1、实测分享!wepoker透视...
一分钟揭秘!poker红龙辅助... 一分钟揭秘!poker红龙辅助(辅助挂)其实有挂(有挂讲解);1)poker红龙辅助有没有挂:进一步...
推荐十款!如何下载wpk透视版... 推荐十款!如何下载wpk透视版(辅助挂)一贯是真的有挂(真的有挂)如何下载wpk透视版是不是有人用挂...
必知教程!破解辅助插件wepo... 必知教程!破解辅助插件wepoker(辅助挂)好像是真的有挂(有挂方法);暗藏猫腻,小编详细说明破解...
玩家必看!德州真人透视脚本(辅... 玩家必看!德州真人透视脚本(辅助挂)好像存在有挂(有挂秘笈)1、德州真人透视脚本公共底牌简单,德州真...
技巧知识分享!pokermas... 技巧知识分享!pokermaster破解版(辅助挂)果然真的是有挂(有挂细节)1、上手简单,内置详细...
我来教大家!wepoker作弊... 我来教大家!wepoker作弊辅助(辅助挂)本来真的有挂(有挂攻略)1、全新机制【wepoker作弊...
玩家爆料!wpk免费辅助(辅助... 玩家爆料!wpk免费辅助(辅助挂)竟然是真的有挂(有挂解惑)1、进入到wpk免费辅助是否有挂之后,能...
推荐十款!wepoker轻量版... 推荐十款!wepoker轻量版透视方法(辅助挂)好像真的是有挂(真实有挂)1)wepoker轻量版透...
让我来分享经验!智星德州可以透... 让我来分享经验!智星德州可以透视吗(辅助挂)竟然有挂(有挂总结)1、智星德州可以透视吗免费脚本咨询教...