使用Paper-Input时,Polymer 3.0 Uncaught DOM异常
发布时间:2021-03-15 21:06 所属栏目:12 来源:网络整理
导读:使用纸张输入时,导入会引发以下异常 Uncaught DOMException: Failed to execute ‘define’ on ‘CustomElementRegistry’: this name has already been used with this registry. 除了为3.0创建模板并添加导入之外,我还没有做任何事情. 迁移工具似乎存在问
使用纸张输入时,导入会引发以下异常
除了为3.0创建模板并添加导入之外,我还没有做任何事情. 迁移工具似乎存在问题,Google曾用它来更新旧组件. 有没有人对此进行排序? 解决方法更新问题是由node_modules中的两个不同版本的iron-meta引起的:./node_modules/@polymer/iron-meta中的旧版本3.0.0-pre.18(已经与Polymer Starter Kit一起安装),以及较新的(3.0.0-pre.19)作为新安装的@聚合物/纸张输入的依赖.最近在Polymer Blog中记录了该修复程序 – 即删除package-lock.json并重新安装node_modules: rm -rf node_modules package-lock.json npm install 错误的堆栈跟踪(下面)似乎表明iron-meta以某种方式注册了两次: polymer-fn.js:43 Uncaught (in promise) DOMException: Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry at Polymer (http://127.0.0.1:8081/node_modules/@polymer/polymer/lib/legacy/polymer-fn.js:43:18) at http://127.0.0.1:8081/node_modules/@polymer/iron-input/node_modules/@polymer/iron-meta/iron-meta.js:131:1 一种解决方法是将customElements.define修补为仅在尚未定义元素时运行: const _customElementsDefine = window.customElements.define; window.customElements.define = function(name,clazz,config) { if (!customElements.get(name)) { _customElementsDefine.call(window.customElements,name,config); } }; 在导入任何元素定义之前运行它.我确认这适用于最新版本的macOS High Sierra,Chrome 66上的纸张输入. 链接您创建的问题以供参考: (编辑:ASP站长网) |
相关内容
网友评论
推荐文章
热点阅读