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>
      ),
    },
  ];
相关推荐
子兮曰9 小时前
OpenClaw入门:从零开始搭建你的私有化AI助手
前端·架构·github
吴仰晖9 小时前
使用github copliot chat的源码学习之Chromium Compositor
前端
1024小神9 小时前
github发布pages的几种状态记录
前端
不像程序员的程序媛11 小时前
Nginx日志切分
服务器·前端·nginx
Daniel李华11 小时前
echarts使用案例
android·javascript·echarts
北原_春希11 小时前
如何在Vue3项目中引入并使用Echarts图表
前端·javascript·echarts
JY-HPS11 小时前
echarts天气折线图
javascript·vue.js·echarts
尽意啊11 小时前
echarts树图动态添加子节点
前端·javascript·echarts
吃面必吃蒜11 小时前
echarts 极坐标柱状图 如何定义柱子颜色
前端·javascript·echarts
O_oStayPositive11 小时前
Vue3使用ECharts
前端·javascript·echarts