polyfills.ts 不会使用 ng new <project> 和 Angular cli 创建

D3u*_*cee 5 javascript polyfills angular-cli angular

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

生成的文件结构

1

我已尝试手动将 polyfills.ts 文件添加到 src 文件夹,但这似乎仍然不起作用。

mik*_*tro 6

由于版本 15 的 polyfills.ts 未生成,而是直接移至 angular.json 中。所以你不必添加它。

\n


小智 6

您可以使用 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"
        ],
**
Run Code Online (Sandbox Code Playgroud)