首页 > 解决方案 > Angular Elements 8 在使用 @Input() 时不适用于 EDGE/IE11

问题描述

我正在尝试使用 Angular Elements 8 创建一些自定义元素,并且在我的@Input() 上使用简单对象作为字符串/数字时效果很好。但是当我想开始使用对象数组时,IE EDGE/11 会抛出异常。

程序

克隆 repo(代码github repo)或执行以下操作:

  1. ng新的“一些名字”

  2. 更新浏览器列表以包含 IE11

  3. ng 生成组件简单列表

  4. 为带有输入的组件编写代码

  5. 提供解决方案(没有我知道的角度元素),一切正常。

  6. 添加角度元素(ng add @angular/elements)

  7. 将模块修改为引导组件作为自定义元素

  8. 使用 EDGE 服务和加载,查看控制台错误

TypeError: Unable to get property 'setInputValue' of undefined or null reference at listItems.set (http://localhost:4300/vendor.js:77430:35) at DefaultDomRenderer2.prototype.setProperty (http://localhost:4300/vendor.js:80310:9) at DebugRenderer2.prototype.setProperty (http://localhost:4300/vendor.js:76553:9) at setElementProperty (http://localhost:4300/vendor.js:73738:5) at checkAndUpdateElementValue (http://localhost:4300/vendor.js:73648:13) at checkAndUpdateElementInline (http://localhost:4300/vendor.js:73576:5) at checkAndUpdateNodeInline (http://localhost:4300/vendor.js:74992:13) at checkAndUpdateNode (http://localhost:4300/vendor.js:74935:9) at debugCheckAndUpdateNode (http://localhost:4300/vendor.js:75957:5) at debugCheckRenderNodeFn (http://localhost:4300/vendor.js:75935:13)"

这是一个已知的缺陷还是我错过了一些重要的东西?

标签: angularangular-elements

解决方案


这是 Angular/Elements 中的一个缺陷。使用 document-register-elements 时,polyfill 不能可靠地调用构造函数。

要解决此问题,请为@webcomponents/custom-elements等自定义元素切换到另一个 polyfill

我为您的项目创建了一个分支并解决了这个问题。


推荐阅读