首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在调整polyfill.ts后,角12不能在边缘或火狐中运行?

为什么在调整polyfill.ts后,角12不能在边缘或火狐中运行?
EN

Stack Overflow用户
提问于 2021-09-29 13:25:42
回答 1查看 792关注 0票数 0

我有一个运行在角12中的应用程序,它在Firefox和Edge中显示一个空白屏幕,但运行在Chrome中。

我遵循了polyfill.ts中的说明

导入'classlist.js';//运行npm install --save classlist.js。导入‘web-动画-js’;//运行npm install --save web-animations-js

我的package.json看起来像这样

代码语言:javascript
复制
    {
      "name": "project-name",
      "version": "0.0.0",
      "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "watch": "ng build --watch --configuration development",
        "test": "ng test"
      },
      "private": true,
      "dependencies": {
        "@angular/animations": "~12.2.0",
        "@angular/cdk": "^12.2.7",
        "@angular/common": "~12.2.0",
        "@angular/compiler": "~12.2.0",
        "@angular/core": "~12.2.0",
        "@angular/flex-layout": "^12.0.0-beta.35",
        "@angular/forms": "~12.2.0",
        "@angular/material": "^12.2.7",
        "@angular/platform-browser": "~12.2.0",
        "@angular/platform-browser-dynamic": "~12.2.0",
        "@angular/router": "~12.2.0",
        "ajv": "^8.6.3",
        "animate.css": "^4.1.1",
        "classlist.js": "^1.1.20150312",
        "core-js": "^2.6.12",
        "hammerjs": "^2.0.8",
        "material-icons": "^1.5.1",
        "ngx-cookie-service": "^12.0.3",
        "ngx-trim-directive": "^1.1.0",
        "rxjs": "~6.6.0",
        "tslib": "^2.3.0",
        "web-animations-js": "^2.3.2",
        "zone.js": "~0.11.4"
      },
      "devDependencies": {
        "@angular-devkit/build-angular": "~12.2.7",
        "@angular/cli": "~12.2.7",
        "@angular/compiler-cli": "~12.2.0",
        "@types/jasmine": "~3.8.0",
        "@types/node": "^12.11.1",
        "jasmine-core": "~3.8.0",
        "karma": "~6.3.0",
        "karma-chrome-launcher": "~3.1.0",
        "karma-coverage": "~2.0.3",
        "karma-jasmine": "~4.0.0",
        "karma-jasmine-html-reporter": "~1.7.0",
        "typescript": "~4.3.5"
      }
    }

这是我的填土

代码语言:javascript
复制
    /**
     * This file includes polyfills needed by Angular and is loaded before the app.
     * You can add your own extra polyfills to this file.
     *
     * This file is divided into 2 sections:
     *   1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
     *   2. Application imports. Files imported after ZoneJS that should be loaded before your main
     *      file.
     *
     * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
     * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
     * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
     *
     * Learn more in https://angular.io/guide/browser-support
     */

    /***************************************************************************************************
     * BROWSER POLYFILLS
     */

    /**
     * IE11 requires the following for NgClass support on SVG elements
     */
    import 'classlist.js';  // Run `npm install --save classlist.js`.

    /**
     * Web Animations `@angular/platform-browser/animations`
     * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
     * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
     */
    import 'web-animations-js';  // Run `npm install --save web-animations-js`.

    /**
     * By default, zone.js will patch all possible macroTask and DomEvents
     * user can disable parts of macroTask/DomEvents patch by setting following flags
     * because those flags need to be set before `zone.js` being loaded, and webpack
     * will put import in the top of bundle, so user need to create a separate file
     * in this directory (for example: zone-flags.ts), and put the following flags
     * into that file, and then add the following code before importing zone.js.
     * import './zone-flags';
     *
     * The flags allowed in zone-flags.ts are listed here.
     *
     * The following flags will work for all browsers.
     *
     * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
     * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
     * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
     *
     *  in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
     *  with the following flag, it will bypass `zone.js` patch for IE/Edge
     *
     *  (window as any).__Zone_enable_cross_context_check = true;
     *
     */

    /***************************************************************************************************
     * Zone JS is required by default for Angular itself.
     */
    import 'zone.js';  // Included with Angular CLI.

为什么脚本不能在Edge和Firefox中运行?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-29 17:55:52

polyfill.ts不再是必需的,因为

这是pollyfill.ts文件中唯一需要的部分

代码语言:javascript
复制
/***************************************************************************************************
 * Zone JS is required by default for Angular itself.
 */
import 'zone.js' // Included with Angular CLI.

/***************************************************************************************************

一切都应该很好,所以请做

npm un classlist.js & npm un web-animations-js

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69377328

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档