lynx: createSelectorQuery() static method

Create a SelectorQuery with the root node of the page as the root.

Syntax

createSelectorQuery(): SelectorQuery;

Parameter

None.

Return Value

A SelectorQuery object with the root node of the page as the root.

Examples

Obtain the position and size of the specified text node:

import { useEffect } from '@lynx-js/react';

function App() {
  useEffect(() => {
    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
  }, []);

  return (
    <view>
      <text id="my-id">Hello, ReactLynx</text>
    </view>
  );
}

Compatibility

LCD tables only load in the browser

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.