For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/lynx-api/selector-query/selector-query-select-unique-id.md.
Lynx
  • 简体中文
  • SelectorQuery: selectUniqueID() method

    通过指定 uid 选择节点。通常用于选择事件源的对应节点。

    uid 是节点的编号。每个节点拥有一个动态分配的独特 uiduid 可通过触发的事件获取。

    语法

    selectUniqueID(uniqueId: string | number): NodesRef;

    参数

    uniqueId

    待选择节点的 uid

    返回值

    代表该查询结果的 NodesRef 对象实例。

    示例

    给点击事件的源节点添加背景颜色:

    const onTap = useCallback((event: ReactLynx.ITouchEvent) => {
      lynx
        .createSelectorQuery()
        .selectUniqueID(event.target.uid)
        .setNativeProps({
          'background-color': 'red',
        })
        .exec();
    }, []);

    兼容性

    LCD tables only load in the browser

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。