有没有办法获取所有 published properties 的列表在 polymer 成分中定义? (例如获取组件公共(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
获取元素的已发布属性列表。 (在 polymer 1.0 element.properties
中也是如此)。
element.getAttribute('attributes)
不会包含 publish
block 中设置的发布属性.
关于javascript - 获取 polymer 已发布的属性列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25170774/