如何使用Polymer查询元素DOM的Selector元素

问题描述 投票:8回答:2

我有我的元素:

<dom-module id="x-el">
  <p class="special-paragraph">first paragraph</p>
  <content></content>
</dom-module>

而且我喜欢用它

<x-el>
  <p class="special-paragraph">second paragraph</p>
</x-el>

在我的必要部分:

Polymer({
  is: 'x-el',

  ready: function () {
    /* this will select all .special-paragraph in the light DOM
       e.g. 'second paragraph' */
    Polymer.dom(this).querySelectorAll('.special-paragraph');

    /* this will select all .special-paragraph in the local DOM
       e.g. 'first paragraph' */
    Polymer.dom(this.root).querySelectorAll('.special-paragraph');

    /* how can I select all .special-paragraph in both light DOM and
       local DOM ? */
  }
});

是否可以使用Polymer内置的?还是应该使用默认的DOM API?

polymer polymer-1.0
2个回答
12
投票

聚合物确实提供了[[not


0
投票
您可以记住的另一种解决方案是:
© www.soinside.com 2019 - 2024. All rights reserved.