- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我需要从 HTMLTextAreaElement 扩展一个自定义元素,以便在表单中使用并直接获取值。但我总是收到 Illegal Constructor Message
HTML:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div>
<working-element></working-element>
</div>
<div>
<crashing-element></crashing-element>
</div>
</body>
<script src="myScript.js">
</html>
Typescript(编译为 ES6 到 myScript.js):
// all works fine
class newElementWorks extends HTMLElement {
constructor(){
super();
console.log('newElementWorks');
}
}
customElements.define('working-element', newElementWorks);
// this one crashes on super() call
class newElementCrash extends HTMLTextAreaElement {
constructor(){
super();
console.log('newElementCrash');
}
}
customElements.define('crashing-element', newElementCrash);
脚本在支持 ES6 和 Custom-Element 的 Chrome 版本 63.0.3239.132 上执行
我已经尝试包括 webcomponents/custom-elements填充
您知道为什么从 HTMLElement 以外的扩展会崩溃吗?
最佳答案
您看到的错误意味着您调用 new
的对象没有 [[construct]]
内部方法。
虽然规范表明您可以扩展
HTML*Element 类,但目前似乎不支持它(参见类似问题:https://github.com/webcomponents/custom-elements/issues/6)所以您只能扩展 HTMLElement
此时。
关于javascript - 扩展 HTMLTextAreaElement 的 HTML5 ES6 自定义元素使非法构造函数崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48422748/
我的代码很长,但我会保持很短,我正在创建一个具有编辑文本内容的 div,当我按下编辑时,div 变得不可见并且文本区域出现,然后如果我们对其进行更改,它会触发执行函数更新的 onchange,这是第一
我正在处理一个表单,我在其中添加了第二个输出字段,在第二个字段中,它具有不同的格式,我已经在我的代码中放置了一个示例。现在我已经部分工作了,但是突然出现了两个问题。 首先,它首先在输出字段中返回 [o
我正在使用 "laracasts/utilities" laravel 包将 laravel 变量传递给 js 文件。以下是我的 Controller 中的代码: JavaScript
我有一个包含 33 个文本区域的页面,如果用户填充其中任何一个,我想存储它们,但也要在 localStorage 的列表/数组中保留空白,这意味着,如果您仅使用条目 0 和条目 33 ,中间的 31
为什么我无法通过Javascript/Jquery获取tinymce textarea中的内容?在我尝试过的所有事情中,它总是给我 [object HTMLTextAreaElement] 作为响应。
在我的程序中,我写了这样一个脚本和表单: jQuery : var message1 = $('#message').val(); 表格: Message 我得到的 var message1 结果
为什么我无法通过 Javascript/Jquery 让 var yourName 显示在文本中?经过我尝试过的所有操作,它给了我 [object HTMLTextAreaElement] 作为响应。
我需要从 HTMLTextAreaElement 扩展一个自定义元素,以便在表单中使用并直接获取值。但我总是收到 Illegal Constructor Message HTML:
我遇到此错误,并且由于此错误而无法发送电子邮件。我在 opencart v2.0.1.1 中添加了一个新的扩展生日提醒我已经搜索了该错误,但无法解决它。请帮忙。该文件的代码是这样的。
我是一名优秀的程序员,十分优秀!