polyfills.ts 不会使用 ng new <project> 和 angular cli

问题描述 投票:0回答:3

我正在研究一些例子并学习角度。当使用角度 cli 创建新项目时,不会生成 polyfills.ts。还有其他人遇到过这个问题吗?这是生成的文件结构。

生成的文件结构

1

我已经尝试手动添加一个 polyfills.ts 文件到 src 文件夹,但似乎仍然没有成功。

javascript angular angular-cli polyfills
3个回答
2
投票

自版本15起polyfills.ts不生成,直接移入angular.json。所以你不必添加它。


0
投票

是的,当使用最新的 angular v15 时,如果您在 pollyfills 属性下看到 angular.json,则不会创建 pollyfills.ts 而不是创建 pollyfills.ts,您可以看到该区域已添加。 enter image description here


0
投票

您可以使用 angular.json 文件在 polyfills.ts 中添加文件

 for this goto angular.json file there you can see polyfills array
    where you can import your localize()

**"index": "src/index.html",
        "main": "src/main.ts",
        "polyfills": [
          "zone.js",
          "@angular/localize/init"
        ],
**
© www.soinside.com 2019 - 2024. All rights reserved.