For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/lynx-api/lynx/lynx-create-selector-query.md.
Lynx
  • English
  • 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.