antd react tour 引导式访问组件解决ref获取不到的问题

我是用了Tab组件,tab分1,2,3步骤,直接用ref不对。所以我找了这种方式,使用原生获取dom

javascript 复制代码
  const [ref1, setRef1] = useState(null);
  const [ref2, setRef2] = useState(null);
  const [ref3, setRef3] = useState(null);
  const [open, setOpen] = useState<boolean>(false);
  useEffect(() => {
    setRef1(document.getElementsByClassName('ant-tabs-tab')[0]);
    setRef2(document.getElementsByClassName('ant-tabs-tab')[1]);
    setRef3(document.getElementsByClassName('ant-tabs-tab')[2]);
  }, [])

  const steps: TourProps['steps'] = [
    {
      title: '',
      description: `1`,
      target: () => ref1,
      placement: 'bottom',
    },
    {
      title: '',
      description: `2`,
      target: () => ref2,
    },
    {
      title: '',
      description:
        `3 also support database data for reliable, efficient, secure and scalable data management.`,
      target: () => ref3,
      placement: 'bottom',
      nextButtonProps: {
        children: <span>Got It</span>,
      },
    },
  ];
  const items: TabsProps['items'] = [
    {
      key: '1',
      label: 'Local',
      children: (
        <LocalData
        
        ></LocalData>
      ),
    },
    {
      key: '2',
      label: 'Cloud',
      children: (
        <CloudStorage
        
        ></CloudStorage>
      ),
    },
    {
      key: '3',
      label: 'SQL',
      children: (
        <SqlDatabases
        
        ></SqlDatabases>
      ),
    },
  ];
相关推荐
JS菌5 小时前
手写一个 AI Agent 全栈项目:从沙箱执行到子智能体的完整实现
前端·人工智能·后端
excel6 小时前
HLS TS 文件损坏的元凶:Git 提交与拉取
前端
Aphasia3116 小时前
https连接传输流程
前端·面试
徐小夕6 小时前
万字长文!千万级文档 RAG 知识库系统落地实践
前端·算法·github
threelab6 小时前
Three.js 物理模拟着色器 | 三维可视化 / AI 提示词
开发语言·前端·javascript·人工智能·3d·着色器
武器大师726 小时前
lv_binding_js 代码解读
开发语言·javascript·ecmascript
kyriewen7 小时前
CSS Container Queries:彻底告别 @media 写到手软,附 5 个真实布局案例
前端·css·面试
圣殿骑士-Khtangc7 小时前
单智能体落地实战:从 ReAct 到 Production-Ready AI Agent 全链路解析
人工智能·react.js
Patrick_Wilson8 小时前
router.replace 之后紧跟 reload,页面为什么无限刷新?
javascript·react.js·浏览器