无法构造"HTMLElement" [英] Failed to construct 'HTMLElement'
本文介绍了无法构造"HTMLElement"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过babel(es2015预设)运行my-widget.js
以产生my-widget-es5.js
.这会导致Polymer错误.
Class constructor PolymerElement cannot be invoked without 'new'
at new MyWidget (my-widget.js:##)
at mw-widget.js [sm]:##
文件结构
out
|
-- my-widget-es5.js
js
|
-- my-widget.js
html
|
-- my-widget.html
my-widget.html
<dom-module id="my-widget">
<template>
<script src="/out/my-widget-es5.js"></script>
</template>
</dom-module>
my-widget.js
class MyWidget extends Polymer.Element {
static get is() {
return 'my-widget';
}
}
customElements.define(MyWidget.is, MyWidget);
解决方案
根据 SO用户@joncarlson:>
您可以使用 my-widget.js
According to SO user @joncarlson: You may find a solution by using the 这篇关于无法构造"HTMLElement"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!class MyWidget extends Polymer.Element {
static get is() {
return 'my-widget';
}
}
customElements.define(MyWidget.is, MyWidget);
解决方案 custom-elements-es5-adapter.js
file proposed as a workaround by Webcomponentsjs.
查看全文