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中正常工作。

相关内容

热门资讯

一分钟了解!红龙poker辅助... 一分钟了解!红龙poker辅助(辅助挂)确实是有挂(有挂方针)1、红龙poker辅助公共底牌简单,红...
技术分享!德普之星私人局辅助免... 技术分享!德普之星私人局辅助免费(辅助挂)切实是有挂(有挂神器)1、该软件可以轻松地帮助玩家将德普之...
一分钟教你!wepoker轻量... 一分钟教你!wepoker轻量版有透视吗(辅助挂)一贯是有挂(真的有挂)1、首先打开wepoker轻...
推荐一款!wepoker免费脚... 推荐一款!wepoker免费脚本咨询(辅助挂)本来有挂(今日头条)wepoker免费脚本咨询透视方法...
每日必备!wepokerplu... 每日必备!wepokerplus到底是挂了吗(辅助挂)好像真的有挂(有挂秘笈)1、游戏颠覆性的策略玩...
玩家必知教程!wpk有那种辅助... 玩家必知教程!wpk有那种辅助吗(辅助挂)本来存在有挂(有挂辅助)1、每一步都需要思考,不同水平的挑...
分享实测!wepoker网页版... 分享实测!wepoker网页版透视方法(辅助挂)都是真的有挂(有挂分析)1、wepoker网页版透视...
玩家实测!wpk插件辅助(辅助... 玩家实测!wpk插件辅助(辅助挂)总是是真的有挂(有挂技巧)1)wpk插件辅助有没有挂:进一步探索w...
查到实测!wepoker怎么看... 查到实测!wepoker怎么看牌型(辅助挂)真是是真的有挂(有挂总结)wepoker怎么看牌型脚本下...
一分钟教你!xpoker怎么作... 一分钟教你!xpoker怎么作弊(辅助挂)总是有挂(有挂方略)xpoker怎么作弊脚本下载中分为三种...