gpt4 book ai didi

angular - 错误 : "@angular/platform-browser/platform-browser" has no exported member 'DOCUMENT'

转载 作者:行者123 更新时间:2023-12-04 18:00:40 27 4
gpt4 key购买 nike

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

包.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 中的“文档”。
有没有办法处理获取文档对象的问题。
提前致谢

最佳答案

您从错误的模块导入。它从 platform-browser 开始折旧。几年前的模块。

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

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

关于angular - 错误 : "@angular/platform-browser/platform-browser" has no exported member 'DOCUMENT' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56359817/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com