无法读取未定义的属性"getDOM" [英] Cannot read property 'getDOM' of undefined

查看:98
本文介绍了无法读取未定义的属性"getDOM"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 angular-2.0 应用迁移到 angular-4.0 .

旁注:我已根据建议添加了动画库.

systemjs.config.js

 '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

      // added animations for 4.0 

      '@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
      '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
      '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',


      // other libraries
      'rxjs': 'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',

此线程中说,我们需要添加

import { ɵgetDOM as getDOM } from '@angular/platform-browser';

但是添加后,它说,

模块'"../node_modules/@angular/platform-b​​rowser/platform-b​​rowser"'没有导出的成员'ɵgetDOM'.

Module '"../node_modules/@angular/platform-browser/platform-browser"' has no exported member 'ɵgetDOM'.

package.json

"@angular/common": "~4.0.1",
"@angular/compiler": "~4.0.1",
"@angular/core": "~4.0.1",
"@angular/forms": "~4.0.1",
"@angular/http": "~4.0.1",
"@angular/animations": "~4.0.1",
"@angular/material": "^2.0.0-beta.3",
"@angular/platform-browser": "~4.0.1",
"@angular/platform-browser-dynamic": "~4.0.1",
"@angular/router": "~3.3.0",
 ...

推荐答案

升级到4.0.0后,我遇到了类似的错误,但是我的问题是@ angular/http.

I had a similar error after upgrading to 4.0.0, but mine was with @angular/http.

结果是我的package.json中没有@ angular/http,但是我的js文件副本存在于最终输出目录(http.umd.js)中.

Turns out that I didn't have @angular/http in my package.json, but I had a copy of the js file existing in my final output directory (http.umd.js).

因此,那里的http版本仍然很旧.因此,请确保您没有从package.json中缺少必需的库之一.

Because of this, the version of http that was out there was still old. So make sure that you aren't missing one of the required libraries from your package.json.

我的第一个线索是@ angular.http在Visual Studio中的Dependencies/npm下是错误的版本,并且旁边有多余的".

My first clue was that @angular.http was the wrong version under Dependencies/npm in Visual Studio and had "extraneous" next to it.

这篇关于无法读取未定义的属性"getDOM"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆