【发布时间】:2017-06-03 19:03:13
【问题描述】:
我有一个带有属性的自定义元素:
class MyElement extends HTMLElement {
...
static get observedAttributes() {
return ["camelCaseAttribute"];
}
set camelCaseAttribute(a) {
this._a = a;
}
...
}
我在我的 HTML 中这样使用它:
<my-element camelCaseAttribute="blubb"></my-element>
camelCaseAttribute 属性在camelCase 中没有设置,但是不使用大写字母可以。为什么?
【问题讨论】:
-
你使用什么样的框架?这很重要
-
@maxkoryukov 他们正在使用 HTML 新技术,允许您扩展
HTMLElements以创建自己的 html 元素 -
我正在使用香草自定义元素。除了一些用于不支持 web 组件的浏览器的 polyfill 之外,它都是普通的。填充物是这个github.com/webcomponents
标签: javascript html web-component custom-element