SelectorQuery.selectAll
收藏
我的收藏

基础库 1.7.0 开始支持本方法,这是一个同步方法。

在当前页面或自定义组件中选择所有匹配选择器的节点,返回一个 NodesRef 对象实例,可以用于获取节点信息。

语法

SelectorQuery.selectAll(selector)

参数说明

selector

类型

默认值

必填

说明

最低支持版本

string


选择器字符串

1.0.0

选择器说明

选择器字符串类似于在 CSS 中使用的选择器,但仅支持下列语法:

  • ID 选择器:#the-id
  • class 选择器(可以连续指定多个):.a-class.another-class
  • 子元素选择器:.the-parent > .the-child
  • 后代选择器:.the-ancestor .the-descendant
  • 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant
  • 多选择器的并集:#a-node, .some-other-nodes

返回值

NodesRef

扫码体验

请使用字节宿主APP扫码

代码示例

开发者工具中预览

Bug & Tip