简体   繁体   English

错误类型错误:无法读取未定义的属性(读取“nativeElement”)

[英]ERROR TypeError: Cannot read properties of undefined (reading 'nativeElement')

I recently upgrade the dependencies within my package.json to their latest versions.我最近将 package.json 中的依赖项升级到最新版本。 The dependencies were outdated by atleast 2 years or maybe more.依赖项已过时至少 2 年或更长时间。 The site i'm working on displays various kinds of graphs and charts and it was working fine before the upgrade to the package.json.我正在处理的站点显示各种图形和图表,并且在升级到 package.json 之前运行良好。 What would be the reason for this?这是什么原因?

This is the updated package.json这是更新后的 package.json

{
  "name": "pipeline-viewer",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^12.0.0",
    "@angular/cdk": "^12.0.0",
    "@angular/common": "^12.0.0",
    "@angular/compiler": "^12.0.0",
    "@angular/core": "^12.0.0",
    "@angular/flex-layout": "^12.0.0-beta.35",
    "@angular/forms": "^12.0.0",
    "@angular/material": "^12.0.0",
    "@angular/material-moment-adapter": "^12.0.0",
    "@angular/platform-browser": "^12.0.0",
    "@angular/platform-browser-dynamic": "^12.0.0",
    "@angular/router": "^12.0.0",
    "@wizpanda/super-gif": "0.0.5",
    "angular-plotly.js": "^4.0.4",
    "bootstrap": "^5.1.3", 
    "moment": "^2.29.1",
    "plotly.js": "^2.5.1",
    "rxjs": "^7.4.0",
    "rxjs-compat": "^6.6.7",
    "zone.js": "^0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^12.0.0",
    "@angular/cli": "^12.0.0",
    "@angular/compiler-cli": "^12.0.0"
  }
}

This is the old package.json that displays the graphs and charts.这是显示图形和图表的旧 package.json。

{
  "name": "pipeline-viewer",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^7.1.4",
    "@angular/cdk": "^7.3.7",
    "@angular/common": "~7.1.0",
    "@angular/compiler": "~7.1.0",
    "@angular/core": "~7.1.0",
    "@angular/flex-layout": "^7.0.0-beta.24",
    "@angular/forms": "~7.1.0",
    "@angular/material": "^7.3.3",
    "@angular/material-moment-adapter": "^8.1.2",
    "@angular/platform-browser": "~7.1.0",
    "@angular/platform-browser-dynamic": "~7.1.0",
    "@angular/router": "~7.1.0",
    "@wizpanda/super-gif": "0.0.5",
    "angular-plotly.js": "^1.3.2",
    "bootstrap": "^4.2.1",
    "moment": "^2.24.0",
    "plotly.js": "^1.49.0",
    "rxjs": "~6.3.3",
    "rxjs-compat": "^6.3.3",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.11.0",
    "@angular/cli": "~7.1.3",
    "@angular/compiler-cli": "~7.1.0"
  }
}

it's related to viewChild changes in Angular +8它与 Angular +8 中的 viewChild 变化有关

Change改变

@ViewChild('element') element: ElementRef;

To

@ViewChild('element', {static: true}) element: ElementRef;
// to access your view Child in ngOnInit

Same thing for ContentChild ContentChild 也一样

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React: Uncaught TypeError: Cannot read properties of undefined (reading '0') error - React: Uncaught TypeError: Cannot read properties of undefined (reading '0') error TypeError:无法读取 json 中未定义(读取“链接”)的属性 - TypeError: Cannot read properties of undefined (reading 'link') in json 未捕获的类型错误:无法读取未定义的属性(读取“问题文本”) - Uncaught TypeError: Cannot read properties of undefined (reading 'questionText') React / Javascript - TypeError:无法读取未定义的属性(读取'json') - React/Javascript - TypeError: Cannot read properties of undefined (reading 'json') 未捕获的类型错误:无法读取未定义的属性(读取“金额”) - Uncaught TypeError: Cannot read properties of undefined (reading 'amount') TypeError:无法读取未定义的属性(读取“product-1”) - TypeError: Cannot read properties of undefined (reading 'product-1') Json TypeError:无法读取未定义的属性(读取“名称”) - Json TypeError: Cannot read properties of undefined (reading 'name') ReactJs:未捕获的类型错误:无法读取未定义的属性(读取“0”) - ReactJs: Uncaught TypeError: Cannot read properties of undefined (reading '0') × TypeError: Cannot read properties of undefined (reading 'map') in reactjs - × TypeError: Cannot read properties of undefined (reading 'map') in reactjs 这个错误的原因是什么,TypeError: Cannot read properties of undefined (reading 'toString') - What's the cause of this error, TypeError: Cannot read properties of undefined (reading 'toString')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM