繁体   English   中英

同一页面中的多个 web 组件在 chrome 中出现错误,例如无法读取 Angular 中未定义(读取创建)的属性

[英]Multiple web components in same page giving error in chrome like cannot read properties of undefined (reading create) in Angular

创建了两个 web 组件:web-comp-1、web-comp-2

当我尝试添加 HTML 页面时,出现如下控制台错误

Uncaught TypeError: Cannot read properties of undefined (reading 'create')
at new m.<computed> (web-comp-1.js:3:2706)
at new t (web-comp-1.js:3:12616)

当我检查线路时,代码是,

(o = (u = F && 1 === a.create.length)? Reflect.construct

使用以下版本和 angular 元素生成 web 组件: "@angular/animations": "14.2.7", "@angular/cdk": "14.2.5", "@angular/common": "14.2.7", " @angular/compiler": "14.2.7", "@angular/core": "14.2.7", "@angular/elements": "14.2.7",

Stackblitz 链接:https://stackblitz.com/edit/web-platform-bkqbag?file=index.html

如果你在 stack blitz 中运行,你不会看到任何错误,你需要下载项目并只在“Chrome”中打开。 此问题仅在 chrome 中发生,在 mozilla 中不发生

在此处输入图像描述

在 package json 中将 document-register-element package 从 1.7.2 升级到 1.14.10,错误消失了。 谢谢@Abolfazl Almas,你的链接让我想到了一个主意

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM