我正在从 0.5 迁移到 1.0。
在阅读时,我注意到声明属性有两种不同的方式,使用hostAttributes
and properties
.
这两个有什么区别?
宿主属性是与元素相应的 Javascript 属性(您在其中声明的)不匹配的属性properties
)。这包括像这样的属性class
, tabindex
, data-*
属性、aria-roles 等。要在创建时声明它们,您必须在hostAttributes
目的。如果要将值绑定到其中,则必须使用$=
(这称为Element.setAttribute
) 而不是=
.
Sources:
- https://www.polymer-project.org/1.0/docs/devguide/registering-elements.html#host-attributes https://www.polymer-project.org/1.0/docs/devguide/registering-elements.html#host-attributes
- https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#attribute-binding https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#attribute-binding
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)