> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# NodesRef

APISummary
Represents a reference to one or more UI nodes. It can be used to invoke UI methods, get and set properties on UI nodes.

`NodesRef` only saves the information needed to find nodes (such as CSS selectors), and does not actually reference a specific node.
The actual node search is only carried out when `SelectorQuery.prototype.exec()` is executed.
Therefore, the node that `NodesRef` reference may not actually exist. In this case, an error will be reported when `exec()` is called.

## Instance Method

[`NodesRef.fields()`](/next/api/lynx-api/nodes-ref/nodes-ref-fields.md)

Query the attributes of the selected node.

[`NodesRef.invoke()`](/next/api/lynx-api/nodes-ref/nodes-ref-invoke.md)

Execute the UI method of the selected node.

[`NodesRef.path()`](/next/api/lynx-api/nodes-ref/nodes-ref-path.md)

Query the path information from the node to the root node of the page.

[`NodesRef.setNativeProps()`](/next/api/lynx-api/nodes-ref/nodes-ref-set-native-props.md)
.mdx)

Directly set the attributes of the selected node.

## Examples

Obtain the position and size of the specified `text` node:

```tsx
class Page extends Component {
  componentDidMount() {
    lynx
      .createSelectorQuery() // create SelectorQuery
      .select('#my-id') // Specify the selector of the target node
      .invoke({
        // Specify the operation for the target node
        method: 'boundingClientRect',
        success: function (res) {
          console.log(res);
        },
        fail: function (res) {
          console.log(res.code, res.data);
        },
      })
      .exec(); // Execute the query
  }

  render() {
    return (
      <view>
        <text id="my-id">...</text>
      </view>
    );
  }
}
```

## Compatibility

**Compatibility Table**

**Query:** `lynx-api.nodes-ref.NodesRef`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/nodes-ref/NodesRef.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| NodesRef | Yes (2.2) | Yes (3.4) | Yes (2.2) | Yes (3.7) | Yes (3.7) | Partial |
| &#96;fields&#96; | Yes (2.8) | Yes (3.4) | Yes (2.8) | Yes (3.7) | Yes (3.7) | No |
| &#96;invoke&#96; | Partial (2.2) | Partial (3.4) | Partial (2.2) | Partial (3.7) | Partial (3.7) | Partial |
| &#96;path&#96; | Yes (2.8) | Yes (3.4) | Yes (2.8) | Yes (3.7) | Yes (3.7) | Yes |
| &#96;setNativeProps&#96; | Yes (2.3) | Yes (3.4) | Yes (2.3) | Yes (3.7) | Yes (3.7) | Yes |

**`NodesRef`**

Represents a reference to one or more UI nodes. It can be used to call methods, get and set properties on UI nodes.

- **Web — Supported (version unknown):** Partial support; Supports invoke, path, and setNativeProps. The fields query is not implemented.

**`` `fields` ``**

Query the attributes of the selected node.

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/nodes-ref/NodesRef.json) · [API Reference](/next/api/lynx-api/nodes-ref/nodes-ref-fields)

- **Web — Not supported:** The Web background runtime does not implement NativeApp.getFields.

**`` `invoke` ``**

Execute the UI method of the selected node.

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/nodes-ref/NodesRef.json) · [API Reference](/next/api/lynx-api/nodes-ref/nodes-ref-invoke)

- **Android — From 2.2:** Partial support; Does not support usage on `NodesRef` created through `SelectorQuery.proptotype.selectAll()`.
- **HarmonyOS — From 3.4:** Partial support; Does not support usage on `NodesRef` created through `SelectorQuery.proptotype.selectAll()`.
- **iOS — From 2.2:** Partial support; Does not support usage on `NodesRef` created through `SelectorQuery.proptotype.selectAll()`.
- **macOS — From 3.7:** Partial support; Does not support usage on `NodesRef` created through `SelectorQuery.proptotype.selectAll()`.
- **Windows — From 3.7:** Partial support; Does not support usage on `NodesRef` created through `SelectorQuery.proptotype.selectAll()`.
- **Web — Supported (version unknown):** Partial support; Does not support usage on `NodesRef` created through `SelectorQuery.prototype.selectAll()`.

**`` `path` ``**

Query the path information from the node to the root node of the page.

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/nodes-ref/NodesRef.json) · [API Reference](/next/api/lynx-api/nodes-ref/nodes-ref-path)

**`` `setNativeProps` ``**

Directly set the attributes of the selected node.

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-api/nodes-ref/NodesRef.json) · [API Reference](/next/api/lynx-api/nodes-ref/nodes-ref-set-native-props)

