3

dart中如何以数组的形式获取类carousel的子元素的类名??

<div class="carousel">
      <div class="galleryCars">
      ....
      </div>
      <div class="galleryCars2">
      ....
      </div>
      <div class="galleryCars3">
      ....
      </div>
      <div class="galleryCars4">
      ....
      </div>
</div>
4

2 回答 2

5

以下是获取一子类名称的方法:

query('.carousel').children.expand((e) => e.classes).toSet();
于 2013-08-19T12:15:00.617 回答
4

快速n脏:

var carousel = query(".carousel");
var classList = [];
carousel.children.forEach((childElement) => classList.addAll(childElement.classes));
print(classList); // [galleryCars,galleryCars2,galleryCars3,galleryCars4]
于 2013-08-19T09:00:47.157 回答