Select the first node that matches the specified selector in the descendants of the root node specified in SelectorQuery
.
CSS selector combination used for matching nodes. The first node that matches the specified selector combination will be returned.
The CSS selector used for matching nodes must satisfy the following syntax:
#
.
tag
props
of a custom component do not belong to attribute
, therefore the attribute
selector cannot be used to match the props
of a custom component.)[attribute]
: Represents elements with an attribute name of attr.[attribute=value]
: Represents elements with an attribute name of attr whose value is exactly value.[attribute*=value]
: Represents elements with an attribute name of attr whose value contains at least one occurrence of value within the string.[attribute^=value]
: Represents elements with an attribute name of attr whose value is prefixed (preceded) by value.[attribute$=value]
: Represents elements with an attribute name of attr whose value is suffixed (followed) by value.Child Element Combinator >
Descendant combinator
(space)
,
A NodesRef
object instance representing this query result.
Please note that at this time, SelectorQuery
will only save the query parameters provided by the user in the NodesRef
object and will not execute the query immediately. Therefore, it is NOT feasible to view node information or determine whether the node can be found in the following way:
Special characters may be parsed as part of a CSS selector or combinator.
For example, select('#m.x')
will be parsed as looking for elements with both id=m
and class=x
attributes, rather than looking for an element with id
as m.x
.
Element manipulations are performed asynchronously after exec()
is executed.
Therefore, it is not feasible to view element information or determine if an element can be found using the following methods:
The correct approach is to examine the error information returned by the node operation functions invoked by the user.
Common reasons include:
A common situation where a node cannot be found is when the node has not been rendered at the time the exec()
function is called, such as when the node is within a conditional statement that is not satisfied.
For example, in the pseudocode below, during the initial render, since show
is false
, the <view id="xxx" />
node will not be rendered. Therefore, attempting to obtain the node in useEffect()
will fail.
The specified node was found, but it does not have the corresponding UI method. Check:
The target node exists in the element tree but lacks an actual UI node.
This issue usually occurs with view
nodes because, for performance reasons, lynx may have optimized the node internally and not actually created it at the UI layer.
If you want to prevent this optimization, try adding an id
to the target node.
LCD tables only load in the browser