簡體   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