【问题标题】:Unable to get property 'apply' of undefined or null reference in angular-4 and using angular-cli无法在 angular-4 和使用 angular-cli 中获取未定义或空引用的属性“应用”
【发布时间】:2017-10-18 00:33:59
【问题描述】:

我正在使用 ng2-admin 仪表板库,我已在一周前更新到最新版本,最近几天我似乎无法在 IE11 中运行我的应用程序,但它在 Chrome 和 Mozilla 浏览器中打开并运行。

下面是我的文件涉及到这个问题,polyfills.ts 和 package.json 和错误,

  1. 错误:

DOM7011:此页面上的代码禁用了前后缓存。欲了解更多信息,请参阅:http://go.microsoft.com/fwlink/?LinkID=291337 我的组合列表 HTML1300:发生导航。 我的组合列表 SCRIPT5007:无法获取未定义或空引用的属性“应用” vendor.bundle.js (23012,5)

  1. 包.json: `{ “名称”:“ng2-admin”, “版本”:“1.0.0”, "description": "Angular 和 Bootstrap 4 管理模板。", “作者”:“Akveo”, "主页": "http://akveo.github.io/ng2-admin/", “存储库”:{ “类型”:“git”, "网址": "https://github.com/akveo/ng2-admin.git" }, “错误”:{ "网址": "https://github.com/akveo/ng2-admin/issues" }, “许可证”:“麻省理工学院”, “脚本”:{ “ng”:“ng”, “rimraf”:“rimraf”, “变更日志”:“标准变更日志”, "开始": "ng 服务 --deploy-url \"http://localhost:4200/\"", “开始:hmr”:“ng服务--hmr”, “开始:aot”:“ng服务--aot”, "start:prod": "ng serve --prod", "start:prod:aot": "ng 服务 --prod --aot", "build": "npm run clean:dist && ng build && gulp default", "build:prod": "npm run build -- --prod", "build:prod:aot": "npm run build:prod -- --aot", "build:ci": "npm run build:prod && npm run build:prod:aot", "build:demo": "npm run build:prod:aot -- --base-href \"http://akveo.com /ng2-admin/\"", “测试”:“ng测试-sr”, "test:coverage": "npm run clean:coverage && ng test -sr -cc", “lint”:“ng lint”, "lint:styles": "stylelint ./src/app/**/*.scss", "lint:ci": "npm run lint && npm run lint:styles", "pree2e": "webdriver-manager 更新 --standalone false --gecko false", “e2e”:“ng e2e”, "clean:dist": "npm run rimraf -- dist", "clean:coverage": "npm run rimraf -- 覆盖率", "docs:deploy": "wintersmith build -C docs && gh-pages -d docs/build", "docs:serve": "wintersmith 预览 -C 文档" }, “私人”:真的, “依赖”:{ "@angular/animations": "4.1.0", "@angular/common": "4.1.0", "@angular/compiler": "4.1.0", "@angular/core": "4.1.0", "@angular/forms": "4.1.0", "@angular/http": "4.1.0", "@angular/platform-b​​rowser": "4.1.0", "@angular/platform-b​​rowser-dynamic": "4.1.0", "@angular/platform-server": "4.1.0", "@angular/路由器": "4.1.0", "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.25", "@ngx-translate/core": "6.0.1", "@ngx-translate/http-loader": "0.0.3", "amcharts3": "github:amcharts/amcharts3", "ammap3": "github:amcharts/ammap3", “angular2-datatable”:“0.6.0”, “animate.css”:“3.5.2”, “引导程序”:“4.0.0-alpha.6”, “chart.js”:“1.1.1”, “图表”:“0.10.1”, “色度-js”:“1.3.3”, “ckeditor”:“4.6.2”, “核心-js”:“2.4.1”, "easy-pie-chart": "2.1.7", “字体真棒”:“4.7.0”, “全日历”:“3.3.1”, “谷歌地图”:“3.2.1”, “离子”:“2.0.1”, “jQuery”:“3.2.1”, “jquery-slimscroll”:“1.3.8”, “传单”:“0.7.7”, “传单地图”:“0.2.1”, “lodash”:“4.17.4”, “ng2-ckeditor”:“1.1.6”, “ng2-completer”:“1.3.1”, “ng2-handsontable”:“0.48.0”, “ng2-slim-loading-bar”:“4.0.0”, “ng2-智能表”:“1.0.3”, "ng2-tree": "2.0.0-alpha.5", “ngx-uploader”:“2.2.5”, “normalize.css”:“6.0.0”, “机器人字体”:“0.7.0”, “rxjs”:“5.1.1”, "zone.js": "0.8.5",

    "@ng-idle/core": "", "@ng-idle/keepalive": "", "时刻": "", "ng2-toastr": "", “owasp-密码强度测试”:“*” }, “开发依赖”:{ "@angular/cli": "1.0.1", "@angular/compiler-cli": "4.1.0", "@types/fullcalendar": "2.7.40", "@types/jasmine": "2.5.38", "@types/jquery": "2.0.41", "@types/jquery.slimscroll": "1.3.30", "@types/lodash": "4.14.61", "@types/node": "6.0.69", “codelyzer”:“2.0.0”, “gh-pages”:“0.12.0”, “茉莉花核”:“2.5.2”, “茉莉花规格报告者”:“3.2.0”, “业力”:“1.4.1”, “业力铬发射器”:“2.0.0”, “业力-cli”:“1.0.1”, “业力覆盖伊斯坦布尔记者”:“0.2.0”, “业力茉莉花”:“1.1.0”, “karma-jasmine-html-reporter”:“0.2.2”, “npm-run-all”:“4.0.2”, “量角器”:“5.1.0”, “rimraf”:“2.6.1”, “标准变更日志”:“1.0.1”, "stylelint": "7.10.1", “ts节点”:“2.0.0”, “tslint”:“4.5.0”, “tslint-eslint-rules”:“3.5.1”, “tslint 语言服务”:“0.9.2”, “打字稿”:“2.3.2”, “打字机”:“0.6.6”, “下划线”:“1.8.3”, “冬天史密斯”:“2.2.5”, "wintersmith-sassy": "1.1.0",

    "del": "*",
    "gulp": "*"
    

    } } `

  2. polyfills.ts ` /**

    • 此文件包含 Angular 所需的 polyfill,并在应用之前加载。
    • 您可以将自己的额外 polyfill 添加到此文件中。 *
    • 此文件分为 2 个部分:
      1. 浏览器 polyfill。这些在加载 ZoneJS 之前应用,并按浏览器排序。
      1. 应用程序导入。在 ZoneJS 之后导入的文件应该在你的 main 之前加载
    • 文件。 *
    • 当前设置适用于所谓的“常青”浏览器;浏览器的最新版本
    • 自动更新自己。这包括 Safari >= 10,Chrome >= 55(包括 Opera),
    • Edge >= 13 在桌面上,iOS 10 和 Chrome 在移动设备上。 *
    • https://angular.io/docs/ts/latest/guide/browser-support.html 中了解更多信息 */

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

    • 浏览器填充 */

    /** IE9、IE10 和 IE11 需要以下所有 polyfill。 **/ // 导入 'core-js/es6/symbol'; // 导入 'core-js/es6/object'; // 导入 'core-js/es6/function'; // 导入 'core-js/es6/parse-int'; // 导入 'core-js/es6/parse-float'; // 导入 'core-js/es6/number'; // 导入 'core-js/es6/math'; // 导入 'core-js/es6/string'; // 导入 'core-js/es6/date'; // 导入 'core-js/es6/array'; // 导入 'core-js/es6/regexp'; // 导入 'core-js/es6/map'; // 导入 'core-js/es6/set';

    /** IE10 和 IE11 需要以下对 SVG 元素的 NgClass 支持 */ // 导入'classlist.js'; // 运行npm install --save classlist.js

    /** IE10 和 IE11 需要以下内容才能支持@angular/animation。 */ // 导入 'web-animations-js'; // 运行npm install --save web-animations-js

    /** Evergreen 浏览器需要这些。 **/ 导入'core-js/es6/reflect'; 导入'core-js/es7/reflect';

    /** 所有 Firefox 浏览器都需要以下内容才能支持 @angular/animation。 **/ // 导入 'web-animations-js'; // 运行npm install --save web-animations-js

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

    • Zone JS 是 Angular 本身所需要的。 */ 导入'zone.js/dist/zone'; // 包含在 Angular CLI 中。

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

      • 应用程序导入 */

      /**

      • 日期、货币、小数和百分比管道。
      • 需要:除 Chrome、Firefox、Edge、IE11 和 Safari 10 之外的所有版本 */ // 导入“国际”; // 运行npm install --save intl

`

【问题讨论】:

  • 在 github 7476075 和 6036 上发现了一些与问题类似的链接,我尝试使用不同的区域版本,例如 0.8.4、0.8.5、0.8.7、0.8。 8,但没有运气

标签: angular


【解决方案1】:

我遇到了和你类似的问题。

我通过添加 polyfill 解决了我的问题:

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
 import 'core-js/es6/symbol';
 import 'core-js/es6/object';
 import 'core-js/es6/function';
 import 'core-js/es6/parse-int';
 import 'core-js/es6/parse-float';
 import 'core-js/es6/number';
 import 'core-js/es6/math';
 import 'core-js/es6/string';
 import 'core-js/es6/date';
 import 'core-js/es6/array';
 import 'core-js/es6/regexp';
 import 'core-js/es6/map';
 import 'core-js/es6/set';

更多详情可以参考我的博文:http://kosmisch.net/Blog/DotNetEssential/Archive/2017/5/20/issue-unable-to-get-property-apply-of-undefined-or-null-reference-occurred-in-angular-4-vs2017-153-aspnet-core-20.html

【讨论】:

  • 谢谢....这解决了我的问题,我可以在 IE11 中打开应用程序,但现在我在控制台上收到另一个错误,与“SCRIPT5022: SecurityError polyfills.bundle. js (6375,25)"....所以你也面临这个问题吗? ...
猜你喜欢
  • 1970-01-01
  • 2017-07-05
  • 2019-05-13
  • 2018-09-29
  • 2017-11-15
  • 2019-06-30
  • 2014-10-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多