错误:“ @ angular / platform-b​​rowser / platform-b​​rowser”没有导出的成员“ DOCUMENT”

时间:2019-05-29 11:42:13

标签: angular

我已将Angular版本从7.1.3更新为8.0.0-rc.3版本。 更新版本后,在ng build --prod命令期间出现以下错误:- / @ angular / platform-b​​rowser / platform-b​​rowser“'没有导出的成员'DOCUMENT'。

Package.json

"devDependencies": {
"@angular/cli": "^8.0.0-rc.3",
"@angular/compiler-cli": "^8.0.0-rc.3",
"@angular/language-service": "^8.0.0-rc.3",
"@ngrx/schematics": "^6.1.2",
"@ngrx/store-devtools": "6.1.2",
"@nrwl/schematics": "7.5.2",
"@types/jasmine": "^3.3.12",
"@types/jasminewd2": "^2.0.6",
"@types/node": "^12.0.0",
"angular-tslint-rules": "^1.14.0",
"codelyzer": "^5.0.1",
"compodoc": "0.0.41",
"husky": "^0.14.3",
"jasmine-core": "^3.4.0",
"jasmine-marbles": "^0.3.1",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^4.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^2.0.0",
"karma-coverage-istanbul-reporter": "^1.4.3",
"karma-html-reporter": "^0.2.7",
"karma-jasmine": "^2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"karma-junit-reporter": "^1.2.0",
"karma-phantomjs-launcher": "^1.0.4",
"lint-staged": "^7.3.0",
"ngrx-store-freeze": "0.2.4",
"prettier": "1.15.3",
"protractor": "^5.4.2",
"rxjs-tslint": "^0.1.7",
"ts-node": "~5.0.1",
"tslint": "^5.16.0",
"tslint-config-prettier": "^1.18.0",
"tslint-sonarts": "^1.9.0",
"tslint-teamcity-reporter": "^2.0.0",
"typescript": "^3.4.5"
 }

组件文件代码为:-

import { DOCUMENT } from '@angular/platform-browser';
@Component({
selector: 'basic-dialog',
styleUrls: ['./dialog.component.scss'],
templateUrl: './dialog.component.html',
animations: [])
])
]
})
export class DialogComponent implements OnChanges, OnDestroy {
  constructor(@Inject(DOCUMENT) private document: Document, private 
  renderer: Renderer2, private element: ElementRef) {}
}

Angular团队已从@ angular / animations中弃用了“ DOCUMENT”。 有什么办法可以解决获取文档对象的问题。 预先感谢

1 个答案:

答案 0 :(得分:0)

您从错误的模块导入。几年前,它已从platform-browser模块中贬值。

import {DOCUMENT} from '@angular/common';

https://angular.io/api/common#types