获取聚合物发布的属性列表 [英] Getting the list of polymer published properties

查看:155
本文介绍了获取聚合物发布的属性列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法获取所有已发布属性的列表在聚合物组件中定义? (例如,获取组件公共API的可用属性)

Is there a way of getting the list of all published properties defined in a polymer component? (e.g. get the available properties of component public API)

<polymer-element name="sample-component"
                 attributes="foo1 foo2" bar="10">
   /* ... */
</polymer-element>

<sample-component foo1="5"></sample-component>


document.querySellector('sample-component').attributes;
// returns bar and foo1 (which have a value assigned to them)
// but I want to get foo1 and foo2


推荐答案

最好使用 element.publish 来获取已发布属性的列表一个元素。 (在聚合物1.0 element.properties 中也是如此)。

It's best to use element.publish to get the list of published properties for an element. (In polymer 1.0 element.properties does the same).

element.getAttribute( 'attributes)将不包含在 发布阻止

element.getAttribute('attributes) won't include the publish properties that are setup in a publish block.

这篇关于获取聚合物发布的属性列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆