You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Planby Timeline实现每行显示单个文本的技术求助

PlanBy 时间线每行显示文本实现方案
  • 借助PlanBy的自定义渲染能力,通过以下两种方式实现每行固定文本:

    1. 使用renderRowHeader渲染行头部文本
      如果你用的是React版本的PlanBy,可在Timeline组件配置中传入renderRowHeader函数,直接返回行对应的文本元素:

      <Timeline
        events={yourEventsData}
        rows={yourRowsData}
        renderRowHeader={(row) => (
          <div style={{ padding: '8px', borderRight: '1px solid #e5e7eb' }}>
            {row.rowLabel}
          </div>
        )}
      />
      

      同时确保你的rows数组中每个对象包含自定义文本字段,比如:

      const yourRowsData = [
        { id: 1, rowLabel: "研发组" },
        { id: 2, rowLabel: "测试组" },
        { id: 3, rowLabel: "产品组" }
      ];
      
    2. 自定义Row组件实现行内固定文本
      若需要在行的主体区域左侧显示文本,可自定义Row组件替换默认组件:

      import { Row } from 'planby';
      
      const CustomTimelineRow = ({ row, children }) => (
        <div style={{ display: 'flex', width: '100%' }}>
          <div style={{ width: '120px', padding: '8px', backgroundColor: '#f9fafb' }}>
            {row.rowLabel}
          </div>
          <div style={{ flex: 1 }}>{children}</div>
        </div>
      );
      
      // 在Timeline中使用自定义组件
      <Timeline
        events={yourEventsData}
        rows={yourRowsData}
        rowComponent={CustomTimelineRow}
      />
      
  • 注意:

    • 确认PlanBy版本为最新稳定版,旧版本可能不支持上述自定义API
    • 可根据需求调整样式,避免与时间线原有样式冲突

内容的提问来源于stack exchange,提问作者SearchingWind

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 22:48:15